1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-15 03:37:17 +00:00
test-tutorial-framework/solvable/src/demo/event_handler_main.py
2018-03-25 16:34:31 +02:00

22 lines
930 B
Python

from tornado.ioloop import IOLoop
from tfw.components.source_code_event_handler import SourceCodeEventHandler
from tfw.components.terminado_event_handler import TerminadoEventHandler
from tfw.components.process_managing_event_handler import ProcessManagingEventHandler
from tfw.config import TFWENV
from tfw.config.logs import logging
log = logging.getLogger(__name__)
if __name__ == '__main__':
ide = SourceCodeEventHandler(key='webide', directory=TFWENV.WEBIDE_WD, exclude=['__pycache__'])
terminado = TerminadoEventHandler(key='shell')
terminado.historymonitor.subscribe_callback(callback=lambda hist: log.debug('User executed command: "{}"'.format(hist[-1])))
processmanager = ProcessManagingEventHandler(key='processmanager', dirmonitor=ide.monitor)
eventhandlers = {ide, terminado, processmanager}
try:
IOLoop.instance().start()
finally:
for eh in eventhandlers: eh.cleanup()