Ejemplo n.º 1
0
 def _stop_period(self, period_name=None, alias=None):
     module: HostModule = self._modules.get_connection(alias)
     table = db.TableSchemaService().tables.Points
     point_name = rf"{period_name or module.alias}"
     db.DataHandlerService().execute(update_sql(table.name, 'End',
                                                HOST_REF=module.host_id, PointName=point_name),
                                     datetime.now().strftime(DB_DATETIME_FORMAT))
Ejemplo n.º 2
0
 def _start_period(self, period_name=None, alias=None):
     module: HostModule = self._modules.get_connection(alias)
     table = db.TableSchemaService().tables.Points
     db.DataHandlerService().execute(insert_sql(table.name, table.columns),
                                     module.host_id, period_name or module.alias,
                                     datetime.now().strftime(DB_DATETIME_FORMAT),
                                     None)
    def start(self):
        self._configuration.update({'event': Event()})
        table = db.TableSchemaService().tables.TraceHost
        db.DataHandlerService().execute(insert_sql(table.name, table.columns),
                                        *(None, self.alias))

        self._host_id = db.DataHandlerService().get_last_row_id
Ejemplo n.º 4
0
def _get_period_marks(period, module_id):
    points = db.TableSchemaService().tables.Points
    start = db.DataHandlerService().execute(
        points.queries.select_state('Start', module_id, period))
    start = None if start == [] else start[0][0]
    end = db.DataHandlerService().execute(
        points.queries.select_state('End', module_id, period))
    end = datetime.now().strftime(DB_DATETIME_FORMAT) if end == [] else end[0][0]
    return dict(start_mark=start, end_mark=end)
Ejemplo n.º 5
0
    def _init(self):
        output_location = BuiltIn().get_variable_value('${OUTPUT_DIR}')
        db.DataHandlerService().init(os.path.join(output_location, self.location), self.file_name, self.cumulative)

        level = BuiltIn().get_variable_value('${LOG LEVEL}')
        logger.setLevel(level)
        rel_log_file_path = os.path.join(self.location, self.file_name)
        abs_log_file_path = os.path.join(output_location, self.location, self.file_name)

        logger.set_file_handler(abs_log_file_path)
        if is_truthy(self._log_to_db):
            db.TableSchemaService().register_table(db.tables.log())
            logger.addHandler(db.services.SQLiteHandler())
        db.DataHandlerService().start()
        logger.warn(f'<a href="{rel_log_file_path}">{self.file_name}</a>', html=True)
 def __init__(self, **kwargs):
     super().__init__(
         table=db.TableSchemaService().tables.sshlibrary_monitor, **kwargs)
     self._tolerance = self.options.get('tolerance')
     self._tolerance_counter = 0
Ejemplo n.º 7
0
 def set_mark(self, mark_name, alias=None):
     module: HostModule = self._modules.get_connection(alias)
     table = db.TableSchemaService().tables.Points
     db.DataHandlerService().execute(update_sql(table.name, 'Mark',
                                                HOST_REF=module.host_id, PointName=mark_name),
                                     datetime.now().strftime(DB_DATETIME_FORMAT))