def madmin_start(arg_args, arg_db_wrapper): global conf_args, device_mappings, db_wrapper, areas conf_args = arg_args db_wrapper = arg_db_wrapper mapping_parser = MappingParser(arg_db_wrapper) device_mappings = mapping_parser.get_devicemappings() areas = mapping_parser.get_areas() app.run(host=arg_args.madmin_ip, port=int(arg_args.madmin_port), threaded=True, use_reloader=False)
def __init__(self, args, listen_address, listen_port, received_mapping, db_wrapper): self.__current_users = {} self.__listen_adress = listen_address self.__listen_port = listen_port self._send_queue = queue.Queue() self.__received = {} # map with received IDs self.__receivedMutex = Lock() self.__requests = {} # map with ID, event mapping self.__requestsMutex = Lock() self.__nextId = 0 self.__idMutex = Lock() self.args = args self.db_wrapper = db_wrapper mapping_parser = MappingParser(self.db_wrapper) self.device_mappings = mapping_parser.get_devicemappings() self.routemanagers = mapping_parser.get_routemanagers() self.auths = mapping_parser.get_auths() self._received_mapping = received_mapping
def madmin_start(arg_args, arg_db_wrapper, ws_server): # load mappings mapping_parser = MappingParser(arg_db_wrapper, arg_args) # load routes statistics(arg_db_wrapper, arg_args, app) control(arg_db_wrapper, arg_args, mapping_parser, ws_server, logger, app) map(arg_db_wrapper, arg_args, mapping_parser, app) config(arg_db_wrapper, arg_args, logger, app) ocr(arg_db_wrapper, arg_args, logger, app) path(arg_db_wrapper, arg_args, app) httpsrv = WSGIServer((arg_args.madmin_ip, int(arg_args.madmin_port)), app.wsgi_app, log=LogLevelChanger) httpsrv.serve_forever()
def load_mappings(db_wrapper): mapping_parser = MappingParser(db_wrapper) device_mappings = mapping_parser.get_devicemappings() routemanagers = mapping_parser.get_routemanagers() auths = mapping_parser.get_auths() return (device_mappings, routemanagers, auths)
if not args.with_madmin: log.fatal( "No mappings.json found - start madmin with with_madmin in config or copy example" ) sys.exit(1) log.fatal( "No mappings.json found - starting setup mode with madmin.") log.fatal("Open Madmin (ServerIP with Port " + str(args.madmin_port) + ") - 'Mapping Editor' and restart.") generate_mappingjson() else: try: mapping_parser = MappingParser(db_wrapper) device_mappings = mapping_parser.get_devicemappings() routemanagers = mapping_parser.get_routemanagers() auths = mapping_parser.get_auths() except KeyError as e: log.fatal( "Could not parse mappings. Please check those. Description: %s" % str(e)) sys.exit(1) mitm_mapper = MitmMapper(device_mappings) ocr_enabled = False for routemanager in routemanagers.keys(): area = routemanagers.get(routemanager, None) if area is None: continue