diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-10-09 22:35:45 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2020-10-13 19:08:59 +0200 |
commit | 481bd7db1d9c3937373c643d6d6aa3164b179839 (patch) | |
tree | d927d50290e4de77de625a80cf54aa327d7f60cf /branding/scripts/gen-providers-json.py | |
parent | aabd6d00acd34273902929bd02dbae47f10a96cc (diff) |
[pkg] some extra branding refactor
Diffstat (limited to 'branding/scripts/gen-providers-json.py')
-rw-r--r-- | branding/scripts/gen-providers-json.py | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/branding/scripts/gen-providers-json.py b/branding/scripts/gen-providers-json.py deleted file mode 100644 index c89217a..0000000 --- a/branding/scripts/gen-providers-json.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python3 - -import configparser -import json -import os -import sys - - -from provider import getDefaultProvider -from provider import getProviderData - -OUTFILE = 'providers.json' -SCRIPT_NAME = 'gen-providers-json' - - -def generateProvidersJSON(configPath, outputJSONPath): - print("output:", outputJSONPath) - config = configparser.ConfigParser() - config.read(configPath) - - # TODO as a first step, we just get the defaultProvider. - # For multi-provider, just add more providers to the dict - - providers = {} - defaultProvider = getDefaultProvider(config) - providers['default'] = defaultProvider - providers['providers'] = [] - providerData = getProviderData(defaultProvider, config) - addCaData(providerData, configPath) - - providers['providers'].append(providerData) - with open(outputJSONPath, 'w', encoding='utf-8') as f: - json.dump(providers, f, ensure_ascii=False, indent=4) - -def addCaData(data, configfile): - provider = data.get('name').lower() - folder, f = os.path.split(configfile) - caFile = os.path.join(folder, provider + '-ca.crt') - if not os.path.isfile(caFile): - bail('[!] Cannot find CA file in {path}'.format(path=caFile)) - with open(caFile) as ca: - data['caCertString'] = ca.read().strip() - -def bail(msg=None): - if not msg: - print("ERROR: not enough arguments!") - print('Usage: {scriptname}.py <config> <output>'.format( - scriptname=SCRIPT_NAME)) - else: - print(msg) - sys.exit(1) - -if __name__ == "__main__": - print("[+] Generating providers.json...") - if len(sys.argv) != 3: - bail() - # TODO get BITMASK_BRANDING folder - get config from there, if possible. - 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 - generateProvidersJSON(sys.argv[1], sys.argv[2]) |