# this line important for socketio msg, otherwise no msg is sent... socketio.init_app(app) # the following test prevents Flask from initializing twice # (because of the Reloader) if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true": ###Initialization of the HardwareObjects # this is to allow Hardware Objects to do # 'from HardwareRepository import ...' sys.path.insert(0, os.path.dirname(__file__)) from HardwareRepository import HardwareRepository as hwr, setLogFile hwr.addHardwareObjectsDirs([os.path.join(os.path.dirname(__file__), 'HardwareObjects')]) hwr_directory = cmdline_options.hwr_directory hwr = hwr.HardwareRepository(os.path.abspath(os.path.expanduser(hwr_directory))) hwr.connect() log_file = cmdline_options.log_file if log_file: setLogFile(log_file) # installs logging handler to send messages to clients import logging_handler root_logger = logging.getLogger() root_logger.setLevel(logging.DEBUG) custom_log_handler = logging_handler.MX3LoggingHandler() custom_log_handler.setLevel(logging.DEBUG) root_logger.addHandler(custom_log_handler) hwr_logger = logging.getLogger("HWR") user_logger = logging.getLogger("user_level_log") queue_logger = logging.getLogger("queue_exec") # hwr_logger.addHandler(custom_log_handler)
# the following test prevents Flask from initializing twice # (because of the Reloader) if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true": ###Initialization of the HardwareObjects # this is to allow Hardware Objects to do # 'from HardwareRepository import ...' sys.path.insert(0, os.path.dirname(__file__)) from HardwareRepository import HardwareRepository as hwr, removeLoggingHandlers removeLoggingHandlers() hwr.addHardwareObjectsDirs( [os.path.join(os.path.dirname(__file__), 'HardwareObjects')]) hwr_directory = cmdline_options.hwr_directory hwr = hwr.HardwareRepository( os.path.abspath(os.path.expanduser(hwr_directory))) hwr.connect() log_formatter = logging.Formatter( '%(asctime)s |%(name)-7s|%(levelname)-7s| %(message)s') log_file = cmdline_options.log_file if log_file: log_file_handler = TimedRotatingFileHandler(log_file, when='midnight', backupCount=1) os.chmod(log_file, 0o666) log_file_handler.setFormatter(log_formatter) # installs logging handler to send messages to clients import logging_handler root_logger = logging.getLogger() root_logger.setLevel(logging.DEBUG)