summaryrefslogtreecommitdiff
path: root/branding/scripts/generate-snap.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2019-07-24 22:25:38 +0200
committerRuben Pollan <meskio@sindominio.net>2019-08-05 11:46:19 -0400
commite709b4209e710eb1bb5e7facff73f72adae66d65 (patch)
tree913005efa1d1adf763b5f499a689c71cb40316f4 /branding/scripts/generate-snap.py
parentba05fbef8501d4dc09c1d41051ca1e820d25bf1d (diff)
[pkg] snap template
Diffstat (limited to 'branding/scripts/generate-snap.py')
-rwxr-xr-xbranding/scripts/generate-snap.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/branding/scripts/generate-snap.py b/branding/scripts/generate-snap.py
new file mode 100755
index 0000000..c3c5419
--- /dev/null
+++ b/branding/scripts/generate-snap.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+import json
+import os
+import sys
+
+import configparser
+
+from provider import getDefaultProvider
+from provider import getProviderData
+
+
+VERSION = os.environ.get('VERSION', 'unknown')
+SCRIPT = 'generate-snap.py'
+
+
+def writeOutput(data, outfile):
+
+ with open(outfile, 'w') as outf:
+ outf.write(json.dumps(data))
+
+
+if __name__ == "__main__":
+ env_provider_conf = os.environ.get('PROVIDER_CONFIG')
+ if env_provider_conf:
+ if os.path.isfile(env_provider_conf):
+ print("[+] Overriding provider config per "
+ "PROVIDER_CONFIG variable")
+ configfile = env_provider_conf
+
+ config = configparser.ConfigParser()
+ config.read(configfile)
+ provider = getDefaultProvider(config)
+ data = getProviderData(provider, config)
+
+ if len(sys.argv) != 2:
+ print('Usage: {} <output_file>'.format(SCRIPT))
+ sys.exit(1)
+
+ outputf = sys.argv[1]
+
+ data['version'] = VERSION
+ writeOutput(data, outputf)