From 9509ea88e163f92ee8ec6ed52e9e689a9d2f1f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sun, 1 Apr 2018 00:45:15 +0200 Subject: [PATCH] Refactor event_handler_main according to pylint suggestions --- solvable/src/event_handler_main.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/solvable/src/event_handler_main.py b/solvable/src/event_handler_main.py index a5862ea..e342534 100644 --- a/solvable/src/event_handler_main.py +++ b/solvable/src/event_handler_main.py @@ -8,11 +8,12 @@ from tfw.config import TFWENV from tfw.message_sender import MessageSender from tfw.networking.event_handlers.server_connector import ServerUplinkConnector from tfw.config.logs import logging -log = logging.getLogger(__name__) + +LOG = logging.getLogger(__name__) def cenator(history): - log.debug('User executed command: "{}"'.format(history[-1])) + LOG.debug('User executed command: "%s"', history[-1]) MessageSender().send('JOHN CENA', 'You\'ve executed "{}"'.format(history[-1])) @@ -23,8 +24,8 @@ def selectdir(history): ServerUplinkConnector().send_to_eventhandler('webide', {'data': {'command': 'selectdir', 'directory': cmd[1]}}) - except Exception: - log.exception('Selectdir failed!') + except IndexError: + LOG.exception('Selectdir failed!') def toggle_next(history): @@ -35,12 +36,13 @@ def toggle_next(history): ServerUplinkConnector().send('messagecontrol', {'data': {'command': 'showbutton', 'next_visibility': toggle_next.button_state}}) - except Exception: - log.exception('Togglenext failed!') + except IndexError: + LOG.exception('Togglenext failed!') toggle_next.button_state = False if __name__ == '__main__': + # pylint: disable=invalid-name ide = SourceCodeEventHandler(key='webide', directory=TFWENV.WEBIDE_WD, exclude=['*.pyc']) terminado = TerminadoEventHandler(key='shell', monitor=BashMonitor(TFWENV.HISTFILE)) terminado.historymonitor.subscribe_callback(cenator) @@ -52,4 +54,5 @@ if __name__ == '__main__': try: IOLoop.instance().start() finally: - for eh in eventhandlers: eh.cleanup() + for eh in eventhandlers: + eh.cleanup()