Root out remaining ambiguous key arguments in EventHandlers

This commit is contained in:
Kristóf Tóth 2018-04-13 20:45:34 +02:00
parent 0cd11f9d64
commit ecec1cde59
5 changed files with 14 additions and 14 deletions

View File

@ -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

View File

@ -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'])

View File

@ -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'])

View File

@ -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)

View File

@ -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