aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Hinds <lhinds@redhat.com>2017-11-16 14:27:46 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-11-16 14:27:46 +0000
commit6a5d426b8244eeb4a4bf0556b9cc0a8a4fee95ed (patch)
tree41a346a47c8564b6604b2155010960d1c9b7a24d
parent21fa9c3018fe39a1060505fea22ff51c52999556 (diff)
parentfad5f4564348d01bc4e6ffb58bef0a49dd8a9b1e (diff)
Merge "Utility script to help create sha256 hashes"
-rw-r--r--utils/generate-sha256.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/utils/generate-sha256.py b/utils/generate-sha256.py
new file mode 100644
index 0000000..c3efc58
--- /dev/null
+++ b/utils/generate-sha256.py
@@ -0,0 +1,30 @@
+import os
+import sys
+import hashlib
+import argparse
+from binaryornot.check import is_binary
+
+hasher = hashlib.sha256()
+parser = argparse.ArgumentParser()
+
+parser.add_argument('--project', help="Full path to project folder", \
+ required=True)
+args = parser.parse_args()
+ignore_dirs = ['.git']
+sys.stdout = open('output.yaml' , 'w')
+
+print("binaries:")
+for root, dirs, files in os.walk(args.project):
+ dirs[:] = [d for d in dirs if d not in ignore_dirs]
+ for file in files:
+ path = os.path.join(root, file)
+ if is_binary(path):
+ with open(path, 'rb') as afile:
+ buf = afile.read()
+ hasher.update(buf)
+ print " {}".format(file)
+ sum = hasher.hexdigest()
+ print " - {}".format(sum)
+
+print("script run complete, now copy and paste contents of output.yaml into \
+ your project exception yaml file")