diff --git a/src/demo/event_handler_main.py b/src/demo/event_handler_main.py index 5cdefdc..ad5e9ce 100644 --- a/src/demo/event_handler_main.py +++ b/src/demo/event_handler_main.py @@ -5,6 +5,7 @@ from tfw.components.terminado_event_handler import TerminadoEventHandler from tfw.components.process_managing_event_handler import ProcessManagingEventHandler 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__) @@ -14,10 +15,21 @@ def cenator(history): MessageSender().send('JOHN CENA', 'You\'ve executed "{}"'.format(history[-1])) +def selectdir(history): + try: + cmd = history[-1].split() + if cmd[0] == 'selectdir': + ServerUplinkConnector().send_to_eventhandler('webide', + {'data': {'command': 'selectdir', + 'directory': cmd[1]}}) + except Exception: + log.exception('Selectdir failed!') + if __name__ == '__main__': ide = SourceCodeEventHandler(key='webide', directory=tfwenv.WEBIDE_WD, exclude=['__pycache__']) terminado = TerminadoEventHandler(key='shell') terminado.historymonitor.subscribe_callback(cenator) + terminado.historymonitor.subscribe_callback(selectdir) processmanager = ProcessManagingEventHandler(key='processmanager', dirmonitor=ide.monitor) eventhandlers = {ide, terminado, processmanager}