def execute(self): """ Run the execution """ self.time_ref.reset() LOGGER.info(None, extra=self.log_dict) return True
def run(self): """ Run the stop mechanism """ # Logging LOGGER.info(None, extra=self.log_dict) # Set all the starters for starter in self.starters: starter.set() # Wait for the execution to finish self.main_thread.runable_sequence_finished.wait() # No backup case if not self.backup_list: return # Sort the backup list key = lambda x: getattr(getattr(x, 'xml_sequence'), 'level') backup_list = list(reversed(sorted(self.backup_list, key=key))) # Link the backup executions first_backup = prev_backup = backup_list[0] for backup in backup_list[1:]: prev_backup.next_execution = backup prev_backup = backup # Run backup first_backup.start() # Wait for backup to finish for backup in backup_list: backup.join()
def stream_sequence_logs(stream, debug_level=logging.INFO): """ Add the custom stream handler to the execution logger """ handler = logging.StreamHandler(stream) handler.setFormatter(SequenceLoggingFormatter()) handler.setLevel(debug_level) LOGGER.addHandler(handler)
def execute(self): """ Run the execution """ for thread in self.wait_list: thread.join() if len(self.block.inputs) > 1: msg = "The {} threads have met".format(len(self.block.inputs)) LOGGER.info(msg, extra=self.log_dict) if len(self.block.outputs) > 1: msg = "{} threads have been started".format(len(self.block.outputs)) LOGGER.info(msg, extra=self.log_dict) self.event.set() return True
def execute(self): """ Run the execution """ for thread in self.wait_list: thread.join() if len(self.block.inputs) > 1: msg = "The {} threads have met".format(len(self.block.inputs)) LOGGER.info(msg, extra=self.log_dict) if len(self.block.outputs) > 1: msg = "{} threads have been started".format(len( self.block.outputs)) LOGGER.info(msg, extra=self.log_dict) self.event.set() return True
def wrapper(self, *args, **kwargs): LOGGER.debug(BES.BG, extra=self.log_dict) res = f(self, *args, **kwargs) if res: LOGGER.debug(BES.OK, extra=self.log_dict) else: LOGGER.debug(BES.KO, extra=self.log_dict) return res
def execute(self): """ Run the execution """ if self.absolute: msg = 'Wait for t={}s'.format(self.time) LOGGER.info(msg, extra=self.log_dict) self.time_ref.wait(self.time) else: msg = 'Wait {}s'.format(self.time) LOGGER.info(msg, extra=self.log_dict) sleep(self.time) LOGGER.info('Done', extra=self.log_dict) return True
def execute(self): """ Run the execution """ if self.absolute: msg = 'Wait for t={}s'.format(self.time) LOGGER.info(msg, extra=self.log_dict) self.time_ref.wait(self.time) else : msg = 'Wait {}s'.format(self.time) LOGGER.info(msg, extra=self.log_dict) sleep(self.time) LOGGER.info('Done', extra=self.log_dict) return True
def execute(self): """ Run the execution """ if not self.sequences: msg = u"No subsequence to run" LOGGER.info(msg, extra=self.log_dict) return True for i, sequence in enumerate(self.sequences): msg = u"Call : {} ".format(self.sequence_id) if self.iteration > 1: msg += u"(iteration {})".format(i + 1) LOGGER.info(msg, extra=self.log_dict) if not sequence.run(): return False if self.tick: msg = 'Tick ({}s)'.format(self.tick) LOGGER.info(msg, extra=self.log_dict) sleep(self.tick) return True
def execute(self): """ Run the execution """ if not self.sequences: msg = u"No subsequence to run" LOGGER.info(msg, extra=self.log_dict) return True for i, sequence in enumerate(self.sequences): msg = u"Call : {} ".format(self.sequence_id) if self.iteration > 1: msg += u"(iteration {})".format(i+1) LOGGER.info(msg, extra=self.log_dict) if not sequence.run(): return False if self.tick: msg = 'Tick ({}s)'.format(self.tick) LOGGER.info(msg, extra=self.log_dict) sleep(self.tick) return True
def critical(self, msg): """ Logging method with critical level """ LOGGER.critical(msg, extra=self._log_dict)
def error(self, msg): """ Logging method with error level """ LOGGER.error(msg, extra=self._log_dict)
def warning(self, msg): """ Logging method with warning level """ LOGGER.warning(msg, extra=self._log_dict)
def info(self, msg): """ Logging method with info level """ LOGGER.info(msg, extra=self._log_dict)
def debug(self, msg): """ Logging method with debug level """ LOGGER.debug(msg, extra=self._log_dict)
def execute(self): """ Method to override """ LOGGER.info(None, extra=self.log_dict) return True
def add_log_handler(handler): """ Add a log handler to the execution logger """ LOGGER.addHandler(handler)