diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2019-07-10 17:12:00 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2019-08-05 11:46:12 -0400 |
commit | e635c5b43df0ed6f28c05429dae126d645ac8717 (patch) | |
tree | 5879cb4d24a00a357264196bcb5bf48bd3500bc7 /branding/scripts | |
parent | 92ea8778813ddffe6187e0ce300638fdefe1bf5e (diff) |
[feat] windows templates
Diffstat (limited to 'branding/scripts')
-rw-r--r-- | branding/scripts/TODO | 2 | ||||
-rw-r--r-- | branding/scripts/__init__.py | 0 | ||||
-rwxr-xr-x | branding/scripts/generate-win.py | 44 | ||||
-rw-r--r-- | branding/scripts/provider.py | 32 | ||||
-rwxr-xr-x | branding/scripts/vendorize.py | 40 |
5 files changed, 85 insertions, 33 deletions
diff --git a/branding/scripts/TODO b/branding/scripts/TODO new file mode 100644 index 0000000..95ca345 --- /dev/null +++ b/branding/scripts/TODO @@ -0,0 +1,2 @@ +-[ ] sanity check scrit +-[ ] assets convertion script diff --git a/branding/scripts/__init__.py b/branding/scripts/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/branding/scripts/__init__.py diff --git a/branding/scripts/generate-win.py b/branding/scripts/generate-win.py new file mode 100755 index 0000000..fb15f22 --- /dev/null +++ b/branding/scripts/generate-win.py @@ -0,0 +1,44 @@ +#!/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') + + +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: generate-win.py <output_file>') + sys.exit(1) + + outputf = sys.argv[1] + + data['applicationNameLower'] = data.get('applicationName').lower() + data['URL'] = data.get('infoURL') + data['version'] = VERSION + writeOutput(data, outputf) diff --git a/branding/scripts/provider.py b/branding/scripts/provider.py new file mode 100644 index 0000000..867007e --- /dev/null +++ b/branding/scripts/provider.py @@ -0,0 +1,32 @@ +import datetime +import os + + +def getDefaultProvider(config): + provider = os.environ.get('PROVIDER') + if provider: + print('[+] Got provider {} from environemnt'.format(provider)) + else: + print('[+] Using default provider from config file') + provider = config['default']['provider'] + return provider + + +def getProviderData(provider, config): + print("[+] Configured provider:", provider) + + c = config[provider] + d = dict() + + keys = ('name', 'applicationName', 'binaryName', + 'providerURL', 'tosURL', 'helpURL', + 'donateURL', 'apiURL', 'geolocationAPI', 'caCertString') + + for value in keys: + d[value] = c.get(value) + + d['timeStamp'] = '{:%Y-%m-%d %H:%M:%S}'.format( + datetime.datetime.now()) + + return d + diff --git a/branding/scripts/vendorize.py b/branding/scripts/vendorize.py index dc19952..59edae0 100755 --- a/branding/scripts/vendorize.py +++ b/branding/scripts/vendorize.py @@ -1,47 +1,20 @@ #!/usr/bin/env python3 -import datetime import os import sys from string import Template import configparser +from provider import getDefaultProvider +from provider import getProviderData + OUTFILE = 'config.go' -INFILE = 'config.go.tmpl' -CONFIGFILE = 'config/vendor.conf' +INFILE = '../templates/golang/config.go' +CONFIGFILE = '../config/vendor.conf' SCRIPT_NAME = 'vendorize' -def getDefaultProvider(config): - provider = os.environ.get('PROVIDER') - if provider: - print('[+] Got provider {} from environemnt'.format(provider)) - else: - print('[+] Using default provider from config file') - provider = config['default']['provider'] - return provider - - -def getProviderData(provider, config): - print("[+] Configured provider:", provider) - - c = config[provider] - d = dict() - - keys = ('name', 'applicationName', 'binaryName', - 'providerURL', 'tosURL', 'helpURL', - 'donateURL', 'apiURL', 'geolocationAPI', 'caCertString') - - for value in keys: - d[value] = c.get(value) - - d['timeStamp'] = '{:%Y-%m-%d %H:%M:%S}'.format( - datetime.datetime.now()) - - return d - - def addCaData(data, configfile): provider = data.get('name').lower() folder, f = os.path.split(configfile) @@ -91,7 +64,8 @@ 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") + print("[+] Overriding provider config per " + "PROVIDER_CONFIG variable") configfile = env_provider_conf if not os.path.isfile(infile): |