Move FSM initialization logic to event_handler_main.py

This commit is contained in:
Kristóf Tóth 2018-06-29 22:08:05 +02:00
parent 0fafa8bcfb
commit 9b3e62852d
2 changed files with 11 additions and 10 deletions

View File

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

View File

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