summaryrefslogtreecommitdiff
path: root/branding/scripts/provider.py
blob: 8904c37843b70d0c7616bda60d0d4d3bdc51af09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import datetime
import os


def getDefaultProvider(config):
    if os.environ.get('VENDOR_PATH'):
        print('[+] Using default provider from config file')
        provider = config['default']['provider']
    else:
        provider = os.environ.get('PROVIDER')
        if provider:
            print('[+] Got provider {} from environment'.format(provider))
    return provider


def getProviderData(provider, config):
    print("[+] Configured provider:", provider)
    try:
        c = config[provider]
    except Exception:
        raise ValueError('Cannot find provider')
        
    d = dict()
    keys = ('name', 'applicationName', 'binaryName', 'auth', 'authEmptyPass',
            'providerURL', 'tosURL', 'helpURL',
            'askForDonations', 'donateURL', 'apiURL',
            'geolocationAPI', 'caCertString')

    for value in keys:
        d[value] = c.get(value)
        if value == 'askForDonations':
            d[value] = bool(d[value])

    d['timeStamp'] = '{:%Y-%m-%d %H:%M:%S}'.format(
        datetime.datetime.now())

    return d