-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathconfig.py
38 lines (29 loc) · 974 Bytes
/
config.py
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
import yaml
import os
import logging
# Some static globals
MAX_HEXDUMP_SIZE = 2048
MAX_DISASM_SIZE = 512
CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.yaml")
class Config(object):
def __init__(self):
self.data = {}
def getConfigPath(self):
return CONFIG_FILE
def getConfig(self):
return self.data
def load(self):
with open(CONFIG_FILE) as jsonfile:
try:
self.data = yaml.safe_load(jsonfile)
except yaml.YAMLError as e:
print('Decoding {} as failed with: {}'.format(CONFIG_FILE, e))
quit()
if 'server' in os.environ:
server = os.environ["server"]
self.data["server"] = { "server": server }
print("Using ENV: server={}, overwriting all others from config.yaml".format(
server))
def get(self, value):
return self.data.get(value, "")
config = Config()