From 9b3e62852d3e807e0ff0c955fc3c4101cee6adef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 29 Jun 2018 22:08:05 +0200 Subject: [PATCH] Move FSM initialization logic to event_handler_main.py --- solvable/src/event_handler_main.py | 11 ++++++++++- solvable/src/tfw_server.py | 10 +--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/solvable/src/event_handler_main.py b/solvable/src/event_handler_main.py index 297f132..e580a9e 100644 --- a/solvable/src/event_handler_main.py +++ b/solvable/src/event_handler_main.py @@ -1,15 +1,19 @@ from ast import literal_eval +from functools import partial from tornado.ioloop import IOLoop from tfw.components import IdeEventHandler, TerminalEventHandler from tfw.components import ProcessManagingEventHandler, BashMonitor from tfw.components import TerminalCommands, LogMonitoringEventHandler +from tfw.components import FSMManagingEventHandler from tfw.networking import MessageSender, TFWServerConnector from tfw.config import TFWENV from tfw.config.logs import logging from tao.config import TAOENV +from test_fsm import TestFSM + LOG = logging.getLogger(__name__) @@ -76,6 +80,11 @@ class TestCommands(TerminalCommands): if __name__ == '__main__': + FiveStepTestFSM = partial(TestFSM, 5) + fsm = FSMManagingEventHandler( # TFW FSM + key='fsm', + fsm_type=FiveStepTestFSM + ) ide = IdeEventHandler( # Web IDE backend key='ide', allowed_directories=[TFWENV.IDE_WD, TFWENV.WEBSERVICE_DIR], @@ -96,7 +105,7 @@ if __name__ == '__main__': process_name='webservice', log_tail=2000 ) - eventhandlers = {ide, terminal, processmanager, logmonitor} + eventhandlers = {ide, terminal, processmanager, logmonitor, fsm} commands = TestCommands(bashrc=f'/home/{TAOENV.USER}/.bashrc') terminal.historymonitor.subscribe_callback(commands.callback) diff --git a/solvable/src/tfw_server.py b/solvable/src/tfw_server.py index b202e92..78766ac 100644 --- a/solvable/src/tfw_server.py +++ b/solvable/src/tfw_server.py @@ -1,17 +1,9 @@ -from functools import partial - from tornado.ioloop import IOLoop from tfw.networking import TFWServer from tfw.config import TFWENV -from tfw.config.logs import logging -from test_fsm import TestFSM - -LOG = logging.getLogger(__name__) if __name__ == '__main__': - FiveStepTestFSM = partial(TestFSM, 5) - TFWServer(FiveStepTestFSM).listen(TFWENV.WEB_PORT) - + TFWServer().listen(TFWENV.WEB_PORT) IOLoop.instance().start()