mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 18:11:32 +00:00
Root out remaining ambiguous key arguments in EventHandlers
This commit is contained in:
parent
0cd11f9d64
commit
ecec1cde59
@ -44,7 +44,7 @@ class DirectoryMonitoringEventHandler(TriggerlessEventHandler):
|
||||
self._monitor = DirectoryMonitor(self._directory)
|
||||
self._monitor.watch() # This runs on a separate thread
|
||||
|
||||
def handle_event(self, key, message):
|
||||
def handle_event(self, message):
|
||||
try:
|
||||
message['data'] = self.commands[message['data']['command']](message['data'])
|
||||
return message
|
||||
|
@ -30,7 +30,7 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
|
||||
self.processmanager = ProcessManager()
|
||||
|
||||
@with_monitor_paused
|
||||
def handle_event(self, key, message):
|
||||
def handle_event(self, message):
|
||||
try:
|
||||
data = message['data']
|
||||
self.processmanager(data['command'], data['process_name'])
|
||||
|
@ -27,7 +27,7 @@ class TerminadoEventHandler(TriggerlessEventHandler):
|
||||
def historymonitor(self):
|
||||
return self._historymonitor
|
||||
|
||||
def handle_event(self, key, message):
|
||||
def handle_event(self, message):
|
||||
LOG.debug('TerminadoEventHandler received event: %s', message)
|
||||
try:
|
||||
message['data'] = self.commands[message['data']['command']](message['data'])
|
||||
|
@ -171,7 +171,7 @@ class WebideEventHandler(TriggerlessEventHandler):
|
||||
data['files'] = self.filemanager.files
|
||||
data['directory'] = self.filemanager.workdir
|
||||
|
||||
def handle_event(self, key, message):
|
||||
def handle_event(self, message):
|
||||
try:
|
||||
data = message['data']
|
||||
message['data'] = self.commands[data['command']](data)
|
||||
|
@ -19,25 +19,25 @@ class EventHandlerBase(ABC):
|
||||
def event_handler_callback(self, msg_parts):
|
||||
message = deserialize_tfw_msg(*msg_parts)
|
||||
key = message['key']
|
||||
response = self.dispatch_handling(key, message)
|
||||
response = self.dispatch_handling(message)
|
||||
response['key'] = key
|
||||
if response is None:
|
||||
return
|
||||
self.server_connector.send(response)
|
||||
|
||||
@abstractmethod
|
||||
def dispatch_handling(self, key, message):
|
||||
def dispatch_handling(self, message):
|
||||
raise NotImplementedError
|
||||
|
||||
def _dispatch_handling(self, key, message):
|
||||
def _dispatch_handling(self, message):
|
||||
# pylint: disable=no-else-return
|
||||
if key != 'reset':
|
||||
return self.handle_event(key, message)
|
||||
if message['key'] != 'reset':
|
||||
return self.handle_event(message)
|
||||
else:
|
||||
return self.handle_reset(message)
|
||||
|
||||
@abstractmethod
|
||||
def handle_event(self, key, message):
|
||||
def handle_event(self, message):
|
||||
raise NotImplementedError
|
||||
|
||||
def handle_reset(self, message):
|
||||
@ -67,8 +67,8 @@ class EventHandlerBase(ABC):
|
||||
|
||||
class TriggerlessEventHandler(EventHandlerBase, ABC):
|
||||
# pylint: disable=abstract-method
|
||||
def dispatch_handling(self, key, message):
|
||||
return self._dispatch_handling(key, message)
|
||||
def dispatch_handling(self, message):
|
||||
return self._dispatch_handling(message)
|
||||
|
||||
|
||||
class TriggeredEventHandler(EventHandlerBase, ABC):
|
||||
@ -77,7 +77,7 @@ class TriggeredEventHandler(EventHandlerBase, ABC):
|
||||
super().__init__(key)
|
||||
self.trigger = trigger
|
||||
|
||||
def dispatch_handling(self, key, message):
|
||||
def dispatch_handling(self, message):
|
||||
if message.get('trigger') == self.trigger:
|
||||
return self._dispatch_handling(key, message)
|
||||
return self._dispatch_handling(message)
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user