Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{'name': 'pausingFinished', 'src': 'pausing', 'dst': 'paused'},
{'name': 'finish', 'src': 'running', 'dst': 'finishing'},
{'name': 'finishingFinished', 'src': 'finishing', 'dst': 'stopped'},
{'name': 'resume', 'src': 'paused', 'dst': 'resuming'},
{'name': 'resumingFinished', 'src': 'resuming', 'dst': 'running'},
{'name': 'abort', 'src': 'pausing', 'dst': 'stopped'},
{'name': 'abort', 'src': 'starting', 'dst': 'stopped'},
{'name': 'abort', 'src': 'resuming', 'dst': 'stopped'}
],
'callbacks': default_callbacks
}
if 'PyQt5' in sys.modules:
super().__init__(cfg=_stateDict, **kwargs)
else:
QtCore.QObject.__init__(self)
Fysom.__init__(self, _stateDict)
self.lock = Mutex()
self.name = name
self.interruptable = False
self.success = False
self.runner = runner
self.ref = references
self.config = config
self.sigDoStart.connect(self._doStart, QtCore.Qt.QueuedConnection)
self.sigDoPause.connect(self._doPause, QtCore.Qt.QueuedConnection)
self.sigDoResume.connect(self._doResume, QtCore.Qt.QueuedConnection)
self.sigDoFinish.connect(self._doFinish, QtCore.Qt.QueuedConnection)
self.sigNextTaskStep.connect(self._doTaskStep, QtCore.Qt.QueuedConnection)
@param dict config: configuration parameter dictionary
"""
_default_callbacks = {'onprerun': self._pre, 'onpostrun': self._post}
_stateList = {
'initial': 'stopped',
'events': [
{'name': 'prerun', 'src': 'stopped', 'dst': 'paused'},
{'name': 'postrun', 'src': 'paused', 'dst': 'stopped'}
],
'callbacks': _default_callbacks
}
if 'PyQt5' in sys.modules:
super().__init__(cfg=_stateList, **kwargs)
else:
QtCore.QObject.__init__(self)
Fysom.__init__(self, _stateList)
self.lock = Mutex()
self.name = name
self.runner = runner
self.ref = references
self.config = config
def __init__(self, callbacks_dict):
self.__NOT_IMPLEMENTED_ERROR = "Classes that inherit from KnittingPlugin should implment {0}"
callbacks_dict = {
'onknit': self.onknit,
#'onknitting': self.onknitting,
'onconfigure': self.onconfigure,
'onfinish': self.onfinish,
}
Fysom.__init__(self,
{'initial': 'activated',
'events': [
## TODO: add more states for handling error management.
{'name': 'configure', 'src': 'activated', 'dst': 'configured'},
{'name': 'configure', 'src': 'configured', 'dst': 'configured'},
{'name': 'configure', 'src': 'finished', 'dst': 'configured'},
{'name': 'configure', 'src': 'error', 'dst': 'configured'},
{'name': 'knit', 'src': 'configured', 'dst': 'knitting'},
{'name': 'finish', 'src': 'knitting', 'dst': 'finished'},
{'name': 'fail', 'src': 'knittng', 'dst': 'error'}
],
'callbacks': callbacks_dict
})
@param dict config: configuration parameter dictionary
"""
_default_callbacks = {'onprerun': self._pre, 'onpostrun': self._post}
_stateList = {
'initial': 'stopped',
'events': [
{'name': 'prerun', 'src': 'stopped', 'dst': 'paused'},
{'name': 'postrun', 'src': 'paused', 'dst': 'stopped'}
],
'callbacks': _default_callbacks
}
if 'PyQt5' in sys.modules:
super().__init__(cfg=_stateList, **kwargs)
else:
QtCore.QObject.__init__(self)
Fysom.__init__(self, _stateList)
self.lock = Mutex()
self.name = name
self.runner = runner
self.ref = references
self.config = config
self.register_interactive_callbacks({
"blocking_user_action": BaseKnittingPlugin.__cli_blocking_action,
"message": BaseKnittingPlugin.__cli_emit_message,
"progress": BaseKnittingPlugin.__cli_log_progress
})
else:
self.register_interactive_callbacks(interactive_callbacks)
# Fysom allows to set hooks before changing states, we set them here.
if callbacks_dict is None:
callbacks_dict = {
'onknit': self.onknit,
'onconfigure': self.onconfigure,
'onfinish': self.onfinish,
}
Fysom.__init__(self, {
'initial': 'activated',
'events': [ # TODO: add more states for handling error management.
{'name': 'configure', 'src': 'activated', 'dst': 'configured'},
{'name': 'configure', 'src': 'configured', 'dst': 'configured'},
{'name': 'configure', 'src': 'finished', 'dst': 'configured'},
{'name': 'configure', 'src': 'error', 'dst': 'configured'},
{'name': 'knit', 'src': 'configured', 'dst': 'knitting'},
{'name': 'finish', 'src': 'knitting', 'dst': 'finished'},
{'name': 'finish', 'src': 'finished', 'dst': 'finished'},
{'name': 'fail', 'src': 'knitting', 'dst': 'error'}],
'callbacks': callbacks_dict
})