forked from Map-A-Droid/MAD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configmode.py
59 lines (46 loc) · 1.65 KB
/
configmode.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import sys
from threading import Thread
from loguru import logger
from utils.walkerArgs import parseArgs
from db.monocleWrapper import MonocleWrapper
from db.rmWrapper import RmWrapper
from utils.version import MADVersion
from utils.logging import initLogging
args = parseArgs()
os.environ['LANGUAGE'] = args.language
initLogging(args)
def generate_mappingjson():
import json
newfile = {}
newfile['areas'] = []
newfile['auth'] = []
newfile['devices'] = []
newfile['walker'] = []
newfile['devicesettings'] = []
with open('configs/mappings.json', 'w') as outfile:
json.dump(newfile, outfile, indent=4, sort_keys=True)
def start_madmin(args, db_wrapper):
from madmin.madmin import madmin_start
madmin_start(args, db_wrapper)
if __name__ == "__main__":
filename = os.path.join('configs', 'config.ini')
if not os.path.exists(filename):
logger.error('Config.ini not found - check configs folder and copy .example')
sys.exit(1)
filename = os.path.join('configs', 'mappings.json')
if not os.path.exists(filename):
generate_mappingjson()
if args.db_method == "rm":
db_wrapper = RmWrapper(args)
elif args.db_method == "monocle":
db_wrapper = MonocleWrapper(args)
else:
logger.error("Invalid db_method in config. Exiting")
sys.exit(1)
version = MADVersion(args, db_wrapper)
version.get_version()
logger.success('Starting MADmin on port {} - open browser and click "Mapping Editor"', int(args.madmin_port))
t_flask = Thread(name='madmin', target=start_madmin, args=(args, db_wrapper))
t_flask.daemon = False
t_flask.start()