コード例 #1
0
ファイル: main.py プロジェクト: fk0815/brickv
def main(config_filename, gui_config, gui_job, override_csv_file_name,
         override_log_file_name, interrupted_ref):
    """
    This function initialize the data logger and starts the logging process
    """
    config = None
    gui_start = False

    if config_filename != None:  # started via console
        config = load_and_validate_config(config_filename)

        if config == None:
            return None
    else:  # started via GUI
        config = gui_config
        gui_start = True

    if override_csv_file_name != None:
        config['data']['csv']['file_name'] = override_csv_file_name

    if override_log_file_name != None:
        config['debug']['log']['file_name'] = override_log_file_name

    try:
        if config['debug']['log']['enabled']:
            EventLogger.add_logger(
                FileLogger(
                    'FileLogger',
                    log_level_name_to_id(config['debug']['log']['level']),
                    config['debug']['log']['file_name']))

        data_logger = DataLogger(config, gui_job)

        if data_logger.ipcon is not None:
            data_logger.run()

            if not gui_start:
                while not interrupted_ref[0]:
                    try:
                        time.sleep(0.25)
                    except:
                        pass

                data_logger.stop()
                sys.exit(0)
        else:
            raise DataLoggerException(
                DataLoggerException.DL_CRITICAL_ERROR,
                "DataLogger did not start logging process! Please check for errors."
            )

    except Exception as exc:
        EventLogger.critical(str(exc))
        if gui_start:
            return None
        else:
            sys.exit(DataLoggerException.DL_CRITICAL_ERROR)

    return data_logger
コード例 #2
0
ファイル: main.py プロジェクト: Tinkerforge/brickv
def main(config_filename, gui_config, gui_job, override_csv_file_name,
         override_log_file_name, interrupted_ref):
    """
    This function initialize the data logger and starts the logging process
    """
    config = None
    gui_start = False

    if config_filename != None: # started via console
        config = load_and_validate_config(config_filename)

        if config == None:
            return None
    else: # started via GUI
        config = gui_config
        gui_start = True

    if override_csv_file_name != None:
        config['data']['csv']['file_name'] = override_csv_file_name

    if override_log_file_name != None:
        config['debug']['log']['file_name'] = override_log_file_name

    if config['debug']['log']['enabled']:
        EventLogger.add_logger(FileLogger('FileLogger', log_level_name_to_id(config['debug']['log']['level']),
                                          config['debug']['log']['file_name']))

    try:
        data_logger = DataLogger(config, gui_job)

        if data_logger.ipcon is not None:
            data_logger.run()

            if not gui_start:
                while not interrupted_ref[0]:
                    try:
                        time.sleep(0.25)
                    except:
                        pass

                data_logger.stop()
                sys.exit(0)
        else:
            raise DataLoggerException(DataLoggerException.DL_CRITICAL_ERROR,
                                      "DataLogger did not start logging process! Please check for errors.")

    except Exception as exc:
        EventLogger.critical(str(exc))
        if gui_start:
            return None
        else:
            sys.exit(DataLoggerException.DL_CRITICAL_ERROR)

    return data_logger
コード例 #3
0
ファイル: setup_dialog.py プロジェクト: fscherwi/brickv
    def btn_load_config_clicked(self):
        filename = get_open_file_name(get_main_window(), 'Load Config',
                                      get_home_path(), 'JSON Files (*.json)')

        if len(filename) == 0:
            return

        config = load_and_validate_config(filename)

        if config == None:
            QMessageBox.warning(get_main_window(), 'Load Config',
                                'Could not load config from file! See Debug tab for details.',
                                QMessageBox.Ok)
            return

        self.update_setup_tab(config)
        self.update_devices_tab(config)
コード例 #4
0
ファイル: setup_dialog.py プロジェクト: daniz185/brickv
    def btn_load_config_clicked(self):
        filename = get_open_file_name(self, 'Load Config',
                                      get_home_path(), 'JSON Files(*.json);;All Files(*)')

        if len(filename) == 0:
            return

        config = load_and_validate_config(filename)

        if config == None:
            QMessageBox.warning(self, 'Load Config',
                                'Could not load config from file! See Debug tab for details.',
                                QMessageBox.Ok)
            return

        self.update_setup_tab(config)
        self.update_devices_tab(config)
コード例 #5
0
ファイル: main.py プロジェクト: fscherwi/brickv
def main(config_filename, gui_config, gui_job):
    """
    This function initialize the data logger and starts the logging process
    """
    config = None
    gui_start = False

    if config_filename != None:  # started via console
        config = load_and_validate_config(config_filename)

        if config == None:
            return None
    else:  # started via GUI
        config = gui_config
        gui_start = True

    if config['debug']['log']['enabled']:
        EventLogger.add_logger(
            FileLogger('FileLogger',
                       log_level_name_to_id(config['debug']['log']['level']),
                       config['debug']['log']['file_name']))

    data_logger = None
    try:
        data_logger = DataLogger(config, gui_job)

        if data_logger.ipcon is not None:
            data_logger.run()
            if not gui_start:
                __exit_condition(data_logger)
        else:
            raise DataLoggerException(
                DataLoggerException.DL_CRITICAL_ERROR,
                "DataLogger did not start logging process! Please check for errors."
            )

    except Exception as exc:
        EventLogger.critical(str(exc))
        if gui_start:
            return None
        else:
            sys.exit(DataLoggerException.DL_CRITICAL_ERROR)

    return data_logger
コード例 #6
0
ファイル: main.py プロジェクト: fscherwi/brickv
def main(config_filename, gui_config, gui_job):
    """
    This function initialize the data logger and starts the logging process
    """
    config = None
    gui_start = False

    if config_filename != None: # started via console
        config = load_and_validate_config(config_filename)

        if config == None:
            return None
    else: # started via GUI
        config = gui_config
        gui_start = True

    if config['debug']['log']['enabled']:
        EventLogger.add_logger(FileLogger('FileLogger', log_level_name_to_id(config['debug']['log']['level']),
                                          config['debug']['log']['file_name']))

    data_logger = None
    try:
        data_logger = DataLogger(config, gui_job)

        if data_logger.ipcon is not None:
            data_logger.run()
            if not gui_start:
                __exit_condition(data_logger)
        else:
            raise DataLoggerException(DataLoggerException.DL_CRITICAL_ERROR,
                                      "DataLogger did not start logging process! Please check for errors.")

    except Exception as exc:
        EventLogger.critical(str(exc))
        if gui_start:
            return None
        else:
            sys.exit(DataLoggerException.DL_CRITICAL_ERROR)

    return data_logger