1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-07-06 11:48:46 +00:00

Refactor event_handler_main according to pylint suggestions

This commit is contained in:
Kristóf Tóth 2018-04-01 00:45:15 +02:00
parent f9c87d9a31
commit 9509ea88e1

View File

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