1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-15 04:37:17 +00:00
test-tutorial-framework/solvable/src/event_handler_main.py

81 lines
2.5 KiB
Python
Raw Normal View History

2019-06-10 13:35:09 +00:00
import logging
2019-06-28 15:36:03 +00:00
from sys import stderr
from functools import partial
from tornado.ioloop import IOLoop
2018-07-26 12:00:24 +00:00
from tfw.fsm import YamlFSM
2019-06-28 13:12:27 +00:00
from tfw.builtins import IdeEventHandler, TerminalEventHandler, FrontendEventHandler
from tfw.builtins import LogMonitoringEventHandler, ProcessManagingEventHandler
2019-07-05 13:37:54 +00:00
from tfw.builtins import DirectorySnapshottingEventHandler, FSMManagingEventHandler
from tfw.config import TFWENV
2019-06-28 15:36:03 +00:00
from tfw.logging import Log, Logger, LogFormatter, VerboseLogFormatter
2019-07-01 12:54:47 +00:00
from tao.config import TAOENV
2019-07-05 13:37:54 +00:00
from custom_event_handlers import MessageFSMStepsEventHandler
2019-07-08 12:12:21 +00:00
from custom_event_handlers import CenatorEventHandler, TestCommandsEventHandler
2019-07-08 09:42:03 +00:00
from signal_handling import setup_signal_handlers
2019-07-05 13:37:54 +00:00
LOG = logging.getLogger(__name__)
def main():
# pylint: disable=unused-variable
2019-06-28 15:36:03 +00:00
Logger([
Log(stderr, LogFormatter(20)),
Log(TFWENV.LOGFILE, VerboseLogFormatter())
]).start()
2019-06-18 16:51:05 +00:00
# TFW component EventHandlers (builtins, required for their respective functionalities)
fsm = FSMManagingEventHandler( # TFW FSM
key='fsm',
2018-07-27 11:59:14 +00:00
fsm_type=partial(
YamlFSM,
'test_fsm.yml',
{} # jinja2 variables, use empty dict to enable jinja2 parsing without any variables
)
)
ide = IdeEventHandler( # Web IDE backend
key='ide',
allowed_directories=[TFWENV.IDE_WD, TFWENV.WEBSERVICE_DIR],
directory=TFWENV.IDE_WD,
exclude=['*.pyc']
)
terminal = TerminalEventHandler( # Web shell backend
2019-06-27 12:38:36 +00:00
key='shell'
)
2019-07-08 12:12:21 +00:00
cenator = CenatorEventHandler('history.bash') # Reacts to terminal commands
commands = TestCommandsEventHandler( # Catches special commands
key='history.bash',
bashrc=f'/home/{TAOENV.USER}/.bashrc'
)
processmanager = ProcessManagingEventHandler( # Handles 'deploy' button clicks
key='processmanager',
log_tail=2000
)
logmonitor = LogMonitoringEventHandler( # Sends live logs of webservice process to frontend
2018-05-30 13:23:54 +00:00
key='logmonitor',
process_name='webservice',
log_tail=2000
)
2018-08-07 15:03:41 +00:00
snapshot = DirectorySnapshottingEventHandler( # Manages filesystem snapshots of directories
key='snapshot',
directories=[
TFWENV.IDE_WD,
TFWENV.WEBSERVICE_DIR
]
)
frontend = FrontendEventHandler() # Proxies frontend API calls to frontend
# Your custom event handlers
message_fsm_steps_eh = MessageFSMStepsEventHandler(
key='test'
)
2019-07-08 09:42:03 +00:00
setup_signal_handlers()
IOLoop.instance().start()
if __name__ == '__main__':
main()