summaryrefslogtreecommitdiffstats
path: root/onlineupdate
diff options
context:
space:
mode:
Diffstat (limited to 'onlineupdate')
-rwxr-xr-xonlineupdate/source/update/updater/gen_cert_header.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/onlineupdate/source/update/updater/gen_cert_header.py b/onlineupdate/source/update/updater/gen_cert_header.py
index a75af1e295fb..3f3798cfb425 100755
--- a/onlineupdate/source/update/updater/gen_cert_header.py
+++ b/onlineupdate/source/update/updater/gen_cert_header.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+import os
import sys
import binascii
@@ -13,6 +15,9 @@ def file_byte_generator(filename):
block = f.read()
return block
+def eprint(*args, **kwargs):
+ print(*args, file=sys.stderr, **kwargs)
+
def create_header(array_name, in_filename):
if sys.version_info >= (3,0):
hexified = ["0x" + binascii.hexlify(bytes([inp])).decode('ascii') for inp in file_byte_generator(in_filename)]
@@ -25,8 +30,13 @@ def create_header(array_name, in_filename):
if __name__ == '__main__':
if len(sys.argv) < 3:
- print('ERROR: usage: gen_cert_header.py array_name update_config_file')
- sys.exit(1);
+ eprint('ERROR: usage: gen_cert_header.py array_name update_config_file')
+ sys.exit(1)
+
+ if not os.path.exists(sys.argv[2]):
+ eprint('The config file %s does not exist'%(sys.argv[2]))
+ sys.exit(1)
+
config = ConfigParser()
config.read(sys.argv[2])
sys.exit(create_header(sys.argv[1], config.get('Updater', 'certificate-der')))