-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsettings.py
More file actions
43 lines (36 loc) · 1.25 KB
/
settings.py
File metadata and controls
43 lines (36 loc) · 1.25 KB
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
38
39
40
41
42
43
import json
import os
from logging import getLogger
log = getLogger('gunicorn.error')
class Settings:
sysConfigFile = '/etc/authservicesapi.conf'
loaded = False
config = {
'cassandra': {
'cluster': 'AuthServices',
'nodes': ['127.0.0.1'],
'port': '9042',
'auth_keyspace': 'authdb'
},
'defaultorg': {
'name': 'example.net',
'defaultadminuser': 'admin',
'defaultadminpass': 'admin',
'defaultadminemail': 'admin@example.net'
}
}
def getConfig():
if not Settings.loaded:
if os.path.isfile(Settings.sysConfigFile):
with open(Settings.sysConfigFile, 'r') as f:
def mergeConfig(a, b):
for key in a.keys():
if key in b:
if isinstance(a[key], dict):
a[key] = mergeConfig(a[key], b[key])
else:
a[key] = b[key]
return a
Settings.config = mergeConfig(Settings.config, json.load(f))
Settings.loaded = True
return Settings.config