mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2025-07-14 01:56:24 +00:00
Simplify *main setup
This commit is contained in:
@ -22,69 +22,61 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
# pylint: disable=unused-variable,too-many-locals
|
||||
# pylint: disable=unused-variable
|
||||
Logger([
|
||||
Log(stderr, LogFormatter(20)),
|
||||
Log(TFWENV.LOGFILE, VerboseLogFormatter())
|
||||
]).start()
|
||||
eh_factory = EventHandlerFactory()
|
||||
|
||||
# TFW component EventHandlers (builtins, required for their respective functionalities)
|
||||
fsm = FSMManagingEventHandler( # TFW FSM
|
||||
eh_factory = EventHandlerFactory()
|
||||
# TFW builtin EventHandlers (required for their respective functionalities)
|
||||
# TFW FSM
|
||||
fsm_eh = eh_factory.build(FSMManagingEventHandler(
|
||||
fsm_type=partial(
|
||||
YamlFSM,
|
||||
'test_fsm.yml',
|
||||
{} # jinja2 variables, use empty dict to enable jinja2 parsing without any variables
|
||||
{} # jinja2 variables, empty dict enables jinja2 without any variables
|
||||
)
|
||||
)
|
||||
fsm_eh = eh_factory.build(fsm)
|
||||
|
||||
ide = IdeEventHandler( # Web IDE backend
|
||||
))
|
||||
# Web IDE backend
|
||||
ide_eh = eh_factory.build(IdeEventHandler(
|
||||
allowed_directories=[TFWENV.IDE_WD, TFWENV.WEBSERVICE_DIR],
|
||||
directory=TFWENV.IDE_WD,
|
||||
exclude=['*.pyc']
|
||||
)
|
||||
ide_eh = eh_factory.build(ide)
|
||||
|
||||
terminal = TerminalEventHandler() # Web shell backend
|
||||
terminal_eh = eh_factory.build(terminal)
|
||||
|
||||
processmanager = ProcessManagingEventHandler( # Handles 'deploy' button clicks
|
||||
))
|
||||
# Web shell backend
|
||||
terminal_eh = eh_factory.build(TerminalEventHandler())
|
||||
# Handles 'deploy' button clicks
|
||||
processmanager_eh = eh_factory.build(ProcessManagingEventHandler(
|
||||
log_tail=2000
|
||||
)
|
||||
processmanager_eh = eh_factory.build(processmanager)
|
||||
|
||||
logmonitor = LogMonitoringEventHandler( # Sends live logs of webservice process to frontend
|
||||
))
|
||||
# Sends live logs of webservice process to frontend
|
||||
logmonitor_eh = eh_factory.build(LogMonitoringEventHandler(
|
||||
process_name='webservice',
|
||||
log_tail=2000
|
||||
)
|
||||
logmonitor_eh = eh_factory.build(logmonitor)
|
||||
|
||||
snapshot = DirectorySnapshottingEventHandler( # Manages filesystem snapshots of directories
|
||||
))
|
||||
# Manages filesystem snapshots of directories
|
||||
snapshot_eh = eh_factory.build(DirectorySnapshottingEventHandler(
|
||||
directories=[
|
||||
TFWENV.IDE_WD,
|
||||
TFWENV.WEBSERVICE_DIR
|
||||
]
|
||||
)
|
||||
snapshot_eh = eh_factory.build(snapshot)
|
||||
))
|
||||
# Proxies frontend API calls to frontend
|
||||
frontend_eh = eh_factory.build(FrontendEventHandler())
|
||||
|
||||
frontend = FrontendEventHandler() # Proxies frontend API calls to frontend
|
||||
frontend_eh = eh_factory.build(frontend)
|
||||
|
||||
# Your custom event handlers
|
||||
cenator = CenatorEventHandler()
|
||||
cenator_eh = eh_factory.build(cenator)
|
||||
|
||||
message_fsm_steps = MessageFSMStepsEventHandler()
|
||||
# Replace these with your custom event handlers
|
||||
# Echoes executed commands to messages
|
||||
cenator_eh = eh_factory.build(CenatorEventHandler())
|
||||
# Echoes FSM steps
|
||||
message_fsm_steps_eh = eh_factory.build(
|
||||
message_fsm_steps,
|
||||
MessageFSMStepsEventHandler(),
|
||||
event_handler_type=FSMAwareEventHandler
|
||||
)
|
||||
|
||||
commands = TestCommandsEventHandler( # Catches special commands
|
||||
# Catches special commands
|
||||
commands_eh = eh_factory.build(TestCommandsEventHandler(
|
||||
bashrc=f'/home/{TAOENV.USER}/.bashrc'
|
||||
)
|
||||
commands_eh = eh_factory.build(commands)
|
||||
))
|
||||
|
||||
setup_signal_handlers()
|
||||
IOLoop.instance().start()
|
||||
|
Reference in New Issue
Block a user