) sys.exit(1) if __name__ == "__main__": check_dependencies() # TODO: globally destroy all threads upon sys.exit() for example install_thread_excepthook() db_wrapper, db_pool_manager = DbFactory.get_wrapper(args) try: instance_id = db_wrapper.get_instance_id() except: instance_id = None data_manager = DataManager(db_wrapper, instance_id) MADPatcher(args, data_manager) data_manager.clear_on_boot() # create folders create_folder(args.file_path) create_folder(args.upload_path) if not args.only_scan and not args.only_routes: logger.error("No runmode selected. \nAllowed modes:\n" " -os ---- start scanner/devicecontroller\n" " -or ---- only calculate routes") sys.exit(1) mitm_receiver_process = None mitm_mapper_manager = None
def data_manager(db_wrapper): dm = DataManager(db_wrapper, None) install_schema(db_wrapper) reload_instance_id(dm) yield dm
logger.error( 'Unable to run with config_mode and only_routes. Only use one option' ) sys.exit(1) if not args.only_scan and not args.only_routes: logger.error("No runmode selected. \nAllowed modes:\n" " -os ---- start scanner/devicecontroller\n" " -or ---- only calculate routes") sys.exit(1) # Elements that should initialized regardless of the functionality being used db_wrapper, db_pool_manager = DbFactory.get_wrapper(args) try: instance_id = db_wrapper.get_instance_id() except Exception: instance_id = None data_manager = DataManager(db_wrapper, instance_id) MADPatcher(args, data_manager) data_manager.clear_on_boot() data_manager.fix_routecalc_on_boot() event = Event(args, db_wrapper) event.start_event_checker() # Do not remove this sleep unless you have solved the race condition on boot with the logger time.sleep(.1) MappingManagerManager.register('MappingManager', MappingManager) mapping_manager_manager = MappingManagerManager() mapping_manager_manager.start() mapping_manager: MappingManager = mapping_manager_manager.MappingManager( db_wrapper, args, data_manager, configmode=args.config_mode) if args.only_routes: logger.info( 'Running in route recalculation mode. MAD will exit once complete')
def data_manager(db_wrapper): db_wrapper.identifier = 1 dm = DataManager(db_wrapper, db_wrapper.identifier) return dm