forked from MeshAddicts/meshinfo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
26 lines (21 loc) · 687 Bytes
/
config.py
File metadata and controls
26 lines (21 loc) · 687 Bytes
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
import datetime
import json
import uuid
class Config:
@classmethod
def load(cls):
config = cls.load_from_file('config.json')
random_uuid = str(uuid.uuid4())
config['broker']['client_id'] = config['broker']['client_id_prefix'] + '-' + random_uuid
config['server']['start_time'] = datetime.datetime.now(datetime.timezone.utc).astimezone()
try:
version_info = cls.load_from_file('version-info.json')
if version_info is not None:
config['server']['version_info'] = version_info
except FileNotFoundError:
pass
return config
@classmethod
def load_from_file(cls, path):
with open(path, 'r') as f:
return json.load(f)