当前位置: 首页>>代码示例>>Python>>正文


Python event_logger.EventLogger类代码示例

本文整理汇总了Python中brickv.data_logger.event_logger.EventLogger的典型用法代码示例。如果您正苦于以下问题:Python EventLogger类的具体用法?Python EventLogger怎么用?Python EventLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EventLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate_xively_section

 def validate_xively_section(self):
     """
     This function validates the xively section out of the configuration
     """
     # TODO: implement xively section validation
     # xively_section = self.json_config._xively
     EventLogger.warning("Xively validation is not yet supported")
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:7,代码来源:configuration_validator.py

示例2: __init__

    def __init__(self, path_to_config=None, configuration=None):
        """
        pathToConfig -- path to the json configuration file
        OR
        configuration -- the configuration itself
        """
        self._configuration = Configuration()
        self._readConfigErr = 0  # Errors which occure during readin

        if path_to_config is None and configuration is None:
            EventLogger.critical(
                "ConfigurationReader needs a path to the configuration file or an actual configuration")
            return

        if path_to_config is not None:
            self.fileName = path_to_config
            self._read_json_config_file()

        if configuration is not None:
            if isinstance(configuration, Configuration):
                self._configuration = configuration
            else:
                self.map_dict_to_config(configuration)

        validator = ConfigurationValidator(self._configuration)
        validator._error_count += self._readConfigErr
        validator.validate()
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:27,代码来源:configuration_validator.py

示例3: validate_devices_section

    def validate_devices_section(self):
        """
            This function validates the devices out of the configuration file
        :return:
        """
        device_definitions = Idf.DEVICE_DEFINITIONS

        for device in self.json_config._devices:
            # name
            blueprint = device_definitions[device[Idf.DD_NAME]]
            if blueprint is None:
                EventLogger.critical(
                    self._generate_device_error_message(uid=device[Idf.DD_UID],
                                                        tier_array=["general"], msg="no such device available"))
                continue  # next device

            # uid
            if not Utilities.is_valid_string(device[Idf.DD_UID], 3) or device[Idf.DD_UID] == Idf.DD_UID_DEFAULT:
                EventLogger.critical(
                    self._generate_device_error_message(uid=device[Idf.DD_UID],
                                                        tier_array=["general"], msg="the UID from '"+device[Idf.DD_NAME]+"' is invalid"))

            device_values = device[Idf.DD_VALUES]
            blueprint_values = blueprint[Idf.DD_VALUES]
            # values
            for device_value in device_values:
                logged_values = 0
                if device_value not in blueprint_values:
                    EventLogger.critical(
                        self._generate_device_error_message(uid=device[Idf.DD_UID],
                                                            tier_array=["values"],
                                                            msg="invalid value " + str(device_value)))
                else:
                    # interval
                    interval = device_values[device_value][Idf.DD_VALUES_INTERVAL]
                    if not self._is_valid_interval(interval):
                        EventLogger.critical(
                            self._generate_device_error_message(uid=device[Idf.DD_UID],
                                                                tier_array=["values"],
                                                                msg="invalid interval " + str(interval)))
                    # subvalue
                    try:
                        subvalues = device_values[device_value][Idf.DD_SUBVALUES]
                        for value in subvalues:
                            if not type(subvalues[value]) == bool:  # type check for validation
                                EventLogger.critical(
                                    self._generate_device_error_message(
                                        uid=device[Idf.DD_UID],
                                        tier_array=["values"],
                                        msg="invalid type " + str(value)))
                            else:
                                if subvalues[value]:  # value check for "lines per second" calculation
                                    logged_values += 1

                    except KeyError:
                        if interval > 0:  # just one value to log
                            logged_values += 1

                    if interval > 0:
                        self._log_space_counter.add_lines_per_second(interval / 1000 * logged_values)
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:60,代码来源:configuration_validator.py

示例4: btn_remove_device_clicked

    def btn_remove_device_clicked(self):
        """
            Removes selected Device
        """
        selected_item = self.tree_devices.selectedItems()
        for index in range(0, len(selected_item)):
            try:
                if selected_item[index] is None:
                    continue

                device_name = selected_item[index].text(0)
                device_id = selected_item[index].text(1)

                if selected_item[index].text(0) not in Identifier.DEVICE_DEFINITIONS:
                    # have to find the parent
                    current_item = selected_item[0]

                    while True:
                        if current_item.parent() is None:
                            if current_item.text(0) not in Identifier.DEVICE_DEFINITIONS:
                                EventLogger.error("Cant remove device: " + selected_item[index].text(0))
                                device_name = ""
                                device_id = ""
                                break
                            else:
                                device_name = current_item.text(0)
                                device_id = current_item.text(1)
                                break
                        else:
                            current_item = current_item.parent()

                self.remove_item_from_tree(device_name, device_id)
            except Exception as e:
                if not str(e).startswith("wrapped C/C++ object"):
                    EventLogger.error("Cant remove device: " + str(e))  # was already removed
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:35,代码来源:logger_setup.py

示例5: _btn_add_device_clicked

    def _btn_add_device_clicked(self):
        """
            Add the selected device from the list/DataLogger-Config.
        """
        items = self.list_widget.selectedItems()
        cur_dev = GuiConfigHandler.get_simple_blueprint(self.Ui_Logger)
        for item in items:
            name = item.text()
            if name == self._no_connected_device_string or name == self._list_separator_string:
                # ignore those
                continue

            dev_name, uid = Utilities.parse_device_name(name)
            dev = GuiConfigHandler.get_device_blueprint(dev_name)
            if dev is None:
                EventLogger.debug("DeviceDialog._btn_add_device_clicked: Blueprint(" + str(dev_name) + ") was None!")
                continue

            if uid is not None:
                if self.__is_device_in_list(dev_name, uid, cur_dev):
                    continue
                # else
                dev[Identifier.DD_UID] = uid

            else:
                dev[Identifier.DD_UID] = Identifier.DD_UID_DEFAULT

            self._logger_window.add_item_to_tree(dev)
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:28,代码来源:device_dialog.py

示例6: __init__

    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint)

        self._gui_logger = GUILogger("GUILogger", EventLogger.EVENT_LOG_LEVEL)
        self._gui_job = None
        EventLogger.add_logger(self._gui_logger)

        # FIXME better way to find interval and uids in tree_widget?!
        self.__tree_interval_tooltip = "Interval in milliseconds"
        self.__tree_uid_tooltip = "UID must be at least 3 Character long"
        self.data_logger_thread = None
        self.tab_console_warning = False

        self.logger_device_dialog = None

        # Code Inspector
        self.host_infos = None
        self.last_host = None
        self.host_index_changing = None

        # if self._table_widget is not None:#FIXME rework this like the console_tab <-- what does that mean?!
        # self.jobs.append()

        self.setupUi(self)
        self.widget_initialization()
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:26,代码来源:logger_setup.py

示例7: update_devices_tab

    def update_devices_tab(self, config):
        EventLogger.debug('Updating devices tab from config')

        self.model_devices.removeRows(0, self.model_data.rowCount())

        for device in config['devices']:
            self.add_device_to_tree(device)
开发者ID:fscherwi,项目名称:brickv,代码行数:7,代码来源:setup_dialog.py

示例8: signal_handler

def signal_handler(interrupted_ref, signum, frame):
    """
    This function handles the ctrl + c exit condition
    if it's raised through the console
    """
    EventLogger.info('Received SIGINT/SIGTERM')
    interrupted_ref[0] = True
开发者ID:Tinkerforge,项目名称:brickv,代码行数:7,代码来源:main.py

示例9: _rolling_file

 def _rolling_file(self):
     f_size = os.path.getsize(self._file_path)
     if f_size > self._file_size:
         # self.set_file_path(self._create_new_file_name(self._file_path))
         EventLogger.info(
             "Max Filesize(" + "%.3f" % (self._file_size / 1024.0 / 1024.0) + " MB) reached! Rolling Files...")
         self._roll_files()
开发者ID:fscherwi,项目名称:brickv,代码行数:7,代码来源:utils.py

示例10: update_setup_tab

    def update_setup_tab(self, config):
        EventLogger.debug('Updating setup tab from config')

        name = config['hosts']['default']['name']
        port = config['hosts']['default']['port']
        secret = config['hosts']['default']['secret']

        i = self.combo_host.findText(name)
        if i >= 0:
            self.combo_host.setCurrentIndex(i)
        else:
            self.combo_host.insertItem(0, name, (port, secret != None, secret))
            self.combo_host.setCurrentIndex(0)

        self.spin_port.setValue(port)

        self.check_authentication.setChecked(secret != None)
        self.edit_secret.setText(secret if secret != None else '')

        self.combo_data_time_format.setCurrentIndex(max(self.combo_data_time_format.findData(config['data']['time_format']), 0))
        self.edit_data_time_format_strftime.setText(config['data']['time_format_strftime'])
        self.check_data_to_csv_file.setChecked(config['data']['csv']['enabled'])
        self.edit_csv_file_name.setText(config['data']['csv']['file_name'])

        self.combo_debug_time_format.setCurrentIndex(max(self.combo_debug_time_format.findData(config['debug']['time_format']), 0))
        self.check_debug_to_log_file.setChecked(config['debug']['log']['enabled'])
        self.edit_log_file_name.setText(config['debug']['log']['file_name'])
        self.combo_log_level.setCurrentIndex(max(self.combo_debug_time_format.findData(config['debug']['log']['level']), 0))
开发者ID:Tinkerforge,项目名称:brickv,代码行数:28,代码来源:setup_dialog.py

示例11: _write_header

    def _write_header(self):
        """Writes a csv header into the file"""
        if not self._file_is_empty():
            EventLogger.debug("File is not empty")
            return

        EventLogger.debug("CSVWriter._write_header() - done")
        self._csv_file.writerow(["TIME"] + ["NAME"] + ["UID"] + ["VAR"] + ["RAW"] + ["UNIT"])
        self._raw_file.flush()
开发者ID:Tinkerforge,项目名称:brickv,代码行数:9,代码来源:utils.py

示例12: process_data_csv_section

    def process_data_csv_section(self):
        """
        Information out of the general section will be consumed here
        """
        csv = self._config['data']['csv']

        self.csv_enabled = csv['enabled']
        self.csv_file_name = csv['file_name']

        EventLogger.debug("Logging output to CSV file: " + str(self.csv_enabled))
        EventLogger.debug("Output file path: " + str(self.csv_file_name))
开发者ID:fscherwi,项目名称:brickv,代码行数:11,代码来源:data_logger.py

示例13: main

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
开发者ID:Tinkerforge,项目名称:brickv,代码行数:54,代码来源:main.py

示例14: process_data_csv_section

    def process_data_csv_section(self):
        """
        Information out of the general section will be consumed here
        """
        csv = self._config['data']['csv']

        self.csv_enabled = csv['enabled']
        self.csv_file_name = csv['file_name']

        if self.csv_enabled:
            EventLogger.info("Logging data to CSV file: " + str(self.csv_file_name))
开发者ID:Tinkerforge,项目名称:brickv,代码行数:11,代码来源:data_logger.py

示例15: btn_set_eventfile_clicked

    def btn_set_eventfile_clicked(self):
        """
            Opens a FileSelectionDialog and sets the selected path for the event output file.
        """
        fn = self.__choose_file_dialog('Choose Eventfile destination', "Log-Files (*.log)")

        if fn == "":
            # cancel
            EventLogger.debug("Cancelled select Eventfile-Path.")
            return

        self.line_path_to_eventfile.setText(fn)
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:12,代码来源:logger_setup.py


注:本文中的brickv.data_logger.event_logger.EventLogger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。