def __init__(self, protocol=None): """ Base SignalDirector for singlenode jobs. MultiNode and LMP jobs need to create a suitable derived class as both also require changes equivalent to the old _keep_running functionality. SignalDirector is the link between the Action and the Connection. The Action uses the SignalDirector to interact with the I/O over the Connection. """ self._cur_handler = BaseSignalHandler(protocol) self.protocol = protocol # communicate externally over the protocol API self.connection = None # communicate with the device self.logger = logging.getLogger("dispatcher") self.test_uuid = None
def __init__(self, protocol=None): """ Base SignalDirector for singlenode jobs. MultiNode and LMP jobs need to create a suitable derived class as both also require changes equivalent to the old _keep_running functionality. SignalDirector is the link between the Action and the Connection. The Action uses the SignalDirector to interact with the I/O over the Connection. """ self._cur_handler = BaseSignalHandler(protocol) self.protocol = protocol # communicate externally over the protocol API self.connection = None # communicate with the device self.logger = logging.getLogger("dispatcher") self.test_uuid = None
class SignalDirector(object): # FIXME: create proxy handlers def __init__(self, protocol=None): """ Base SignalDirector for singlenode jobs. MultiNode and LMP jobs need to create a suitable derived class as both also require changes equivalent to the old _keep_running functionality. SignalDirector is the link between the Action and the Connection. The Action uses the SignalDirector to interact with the I/O over the Connection. """ self._cur_handler = BaseSignalHandler(protocol) self.protocol = protocol # communicate externally over the protocol API self.connection = None # communicate with the device self.logger = logging.getLogger("dispatcher") self.test_uuid = None def setup(self, parameters): """ Allows the parent Action to pass extra data to a customised SignalDirector """ pass def signal(self, name, params): handler = getattr(self, "_on_" + name.lower(), None) if not handler and self._cur_handler: handler = self._cur_handler.custom_signal params = [name] + list(params) if handler: try: # The alternative here is to drop the getattr and have a long if:elif:elif:else. # Without python support for switch, this gets harder to read than using # a getattr lookup for the callable (codehelp). So disable checkers: # noinspection PyCallingNonCallable handler(*params) # pylint: disable=star-args except KeyboardInterrupt: raise KeyboardInterrupt except TypeError as exc: # handle serial corruption which can overlap kernel messages onto test output. self.logger.exception(exc) except JobError as exc: self.logger.error("job error: handling signal %s failed: %s", name, exc) return False return True def postprocess_bundle(self, bundle): pass def _on_startrun(self, test_run_id, uuid): # pylint: disable=unused-argument """ runsh.write('echo "<LAVA_SIGNAL_STARTRUN $TESTRUN_ID $UUID>"\n') """ self._cur_handler = None if self._cur_handler: self._cur_handler.start() def _on_endrun(self, test_run_id, uuid): # pylint: disable=unused-argument if self._cur_handler: self._cur_handler.end() def _on_starttc(self, test_case_id): if self._cur_handler: self._cur_handler.starttc(test_case_id) def _on_endtc(self, test_case_id): if self._cur_handler: self._cur_handler.endtc(test_case_id)
class SignalDirector(object): # FIXME: create proxy handlers def __init__(self, protocol=None): """ Base SignalDirector for singlenode jobs. MultiNode and LMP jobs need to create a suitable derived class as both also require changes equivalent to the old _keep_running functionality. SignalDirector is the link between the Action and the Connection. The Action uses the SignalDirector to interact with the I/O over the Connection. """ self._cur_handler = BaseSignalHandler(protocol) self.protocol = protocol # communicate externally over the protocol API self.connection = None # communicate with the device self.logger = logging.getLogger("dispatcher") self.test_uuid = None def setup(self, parameters): """ Allows the parent Action to pass extra data to a customised SignalDirector """ pass def signal(self, name, params): handler = getattr(self, "_on_" + name.lower(), None) if not handler and self._cur_handler: handler = self._cur_handler.custom_signal params = [name] + list(params) if handler: try: # The alternative here is to drop the getattr and have a long if:elif:elif:else. # Without python support for switch, this gets harder to read than using # a getattr lookup for the callable (codehelp). So disable checkers: # noinspection PyCallingNonCallable handler(*params) except TypeError as exc: # handle serial corruption which can overlap kernel messages onto test output. self.logger.exception(str(exc)) except JobError as exc: self.logger.error( "job error: handling signal %s failed: %s", name, exc) return False return True def postprocess_bundle(self, bundle): pass def _on_testset_start(self, set_name): pass def _on_testset_stop(self): pass # noinspection PyUnusedLocal def _on_startrun(self, test_run_id, uuid): # pylint: disable=unused-argument """ runsh.write('echo "<LAVA_SIGNAL_STARTRUN $TESTRUN_ID $UUID>"\n') """ self._cur_handler = None if self._cur_handler: self._cur_handler.start() # noinspection PyUnusedLocal def _on_endrun(self, test_run_id, uuid): # pylint: disable=unused-argument if self._cur_handler: self._cur_handler.end() def _on_starttc(self, test_case_id): if self._cur_handler: self._cur_handler.starttc(test_case_id) def _on_endtc(self, test_case_id): if self._cur_handler: self._cur_handler.endtc(test_case_id)