db.create_all() except Exception as ec: console.error('Error: Database connection!' + str(ec.__class__) + traceback.format_exc()) ServerLogging().log_error(func_name, "Database connection error!") exit(1) from streaming_event_compliance.objects.variable.globalvar import gVars from streaming_event_compliance.services import setup from streaming_event_compliance.services.build_automata import build_automata from streaming_event_compliance.database import dbtools dbtools.empty_tables() setup.init_automata() if gVars.auto_status == 0: start = time.clock() console.secure("Start time: ", start) try: ServerLogging().log_info(func_name, "Building automata...") build_automata.build_automata() except ReadFileException as ec: console.error(ec.message) ServerLogging().log_error(func_name, "Training file cannot be read") except ThreadException as ec: ServerLogging().log_error(func_name, "Error with threads") except Exception as ec: ServerLogging().log_error(func_name, "Error") ends = time.clock() console.secure("[ The Total Time For Training Automata ]", str(ends - start) + "Seconds.") else: console.info("Automata have been created in database and read out! You can use it do compliance checking!") ServerLogging().log_info(func_name, "Automata have been created in database and read out")
app.config['AUTOS_DEFAULT'] = False app.config['THRESHOLD'] = 0.2 app.config['AUTOMATA_FILE'] = 'automata' app.config['CLEINT_DATA_PATH'] = app.config['BASE_DIR'] + 'p_automata' + os.sep app.config['FILE_TYPE'] = '.pdf' app.config['TRAINING_EVENT_LOG_PATH'] = app.config['BASE_DIR'] + 'data' + os.sep + \ 'Simple_Training2.xes' app.config['WINDOW_SIZE'] = list(map(int, re.findall(r"\d+", '[1,2,3,4]'))) app.config['MAXIMUN_WINDOW_SIZE'] = max(app.config['WINDOW_SIZE']) app.config['CHECKING_TYPE'] = 'KEEP_ALL_EVENTS' app.config['SERVER_LOG_PATH'] = app.config[ 'BASE_DIR'] + 'data' + os.sep + 'server.log' app.config['ALERT_TYPE'] = 'RETURN_ONE' console.secure( '[ DEFALUT ]', 'WINDOW_SIZE: ' + str(app.config['WINDOW_SIZE']) + '\t' 'CHECKING_TYPE: ' + app.config['CHECKING_TYPE'] + '\t' + 'ALERT_TYPE: ' + app.config['ALERT_TYPE']) config = configparser.ConfigParser() app.config['CONFIG_PATH'] = app.config['BASE_DIR'] + 'config.ini' config.read(app.config['CONFIG_PATH']) # Checking config['USER-DEFINED']: if config['USER-DEFINED'].get('TRAINING_EVENT_LOG_PATH') and config[ 'USER-DEFINED']['TRAINING_EVENT_LOG_PATH'] is not '': app.config['TRAINING_EVENT_LOG_PATH'] = app.config['BASE_DIR'] + \ config['USER-DEFINED']['TRAINING_EVENT_LOG_PATH'].replace('/', os.sep) if config['USER-DEFINED'].get( 'WINDOW_SIZE') and config['USER-DEFINED']['WINDOW_SIZE'] is not '': ws = list(