mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2025-07-14 00:36:23 +00:00
Comply new package structure
This commit is contained in:
@ -6,16 +6,17 @@ from tornado.ioloop import IOLoop
|
||||
|
||||
from tfw.fsm import YamlFSM
|
||||
from tfw.event_handlers import FSMAwareEventHandler
|
||||
from tfw.builtins import IdeEventHandler, TerminalEventHandler, FrontendEventHandler
|
||||
from tfw.builtins import LogMonitoringEventHandler, ProcessManagingEventHandler
|
||||
from tfw.builtins import DirectorySnapshottingEventHandler, FSMManagingEventHandler
|
||||
from tfw.components.ide import IdeHandler
|
||||
from tfw.components.terminal import TerminalHandler
|
||||
from tfw.components.frontend import FrontendHandler
|
||||
from tfw.components.process_management import ProcessHandler, ProcessLogHandler
|
||||
from tfw.components.snapshots import SnapshotHandler
|
||||
from tfw.components.fsm import FSMHandler
|
||||
from tfw.main import EventHandlerFactory, setup_signal_handlers
|
||||
from tfw.logging import Log, Logger, LogFormatter, VerboseLogFormatter
|
||||
from tfw.config import TFWENV
|
||||
from tao.config import TAOENV
|
||||
from tfw.config import TFWENV, TAOENV
|
||||
|
||||
from custom_event_handlers import MessageFSMStepsEventHandler
|
||||
from custom_event_handlers import CenatorEventHandler, TestCommandsEventHandler
|
||||
from custom_handlers import CenatorHandler, TestCommandsHandler, messageFSMStepsHandler
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -31,7 +32,7 @@ def main():
|
||||
eh_factory = EventHandlerFactory()
|
||||
# TFW builtin EventHandlers (required for their respective functionalities)
|
||||
# TFW FSM
|
||||
fsm_eh = eh_factory.build(FSMManagingEventHandler(
|
||||
fsm_eh = eh_factory.build(FSMHandler(
|
||||
fsm_type=partial(
|
||||
YamlFSM,
|
||||
'test_fsm.yml',
|
||||
@ -39,42 +40,50 @@ def main():
|
||||
)
|
||||
))
|
||||
# Web IDE backend
|
||||
ide_eh = eh_factory.build(IdeEventHandler(
|
||||
ide_eh = eh_factory.build(IdeHandler(
|
||||
allowed_directories=[TFWENV.IDE_WD, TFWENV.WEBSERVICE_DIR],
|
||||
directory=TFWENV.IDE_WD,
|
||||
exclude=['*.pyc']
|
||||
))
|
||||
# Web shell backend
|
||||
terminal_eh = eh_factory.build(TerminalEventHandler())
|
||||
terminal_eh = eh_factory.build(TerminalHandler(
|
||||
port=TFWENV.TERMINADO_PORT,
|
||||
user=TAOENV.USER,
|
||||
workind_directory=TFWENV.TERMINADO_WD,
|
||||
histfile=TFWENV.HISTFILE
|
||||
))
|
||||
# Handles 'deploy' button clicks
|
||||
processmanager_eh = eh_factory.build(ProcessManagingEventHandler(
|
||||
log_tail=2000
|
||||
processmanager_eh = eh_factory.build(ProcessHandler(
|
||||
supervisor_uri=TFWENV.SUPERVISOR_HTTP_URI,
|
||||
log_tail=2000,
|
||||
))
|
||||
# Sends live logs of webservice process to frontend
|
||||
logmonitor_eh = eh_factory.build(LogMonitoringEventHandler(
|
||||
logmonitor_eh = eh_factory.build(ProcessLogHandler(
|
||||
process_name='webservice',
|
||||
supervisor_uri=TFWENV.SUPERVISOR_HTTP_URI,
|
||||
log_tail=2000
|
||||
))
|
||||
# Manages filesystem snapshots of directories
|
||||
snapshot_eh = eh_factory.build(DirectorySnapshottingEventHandler(
|
||||
snapshot_eh = eh_factory.build(SnapshotHandler(
|
||||
directories=[
|
||||
TFWENV.IDE_WD,
|
||||
TFWENV.WEBSERVICE_DIR
|
||||
]
|
||||
],
|
||||
snapshots_dir=TFWENV.SNAPSHOTS_DIR
|
||||
))
|
||||
# Proxies frontend API calls to frontend
|
||||
frontend_eh = eh_factory.build(FrontendEventHandler())
|
||||
frontend_eh = eh_factory.build(FrontendHandler())
|
||||
|
||||
# Replace these with your custom event handlers
|
||||
# Echoes executed commands to messages
|
||||
cenator_eh = eh_factory.build(CenatorEventHandler())
|
||||
cenator_eh = eh_factory.build(CenatorHandler())
|
||||
# Echoes FSM steps
|
||||
message_fsm_steps_eh = eh_factory.build(
|
||||
MessageFSMStepsEventHandler(),
|
||||
messageFSMStepsHandler,
|
||||
event_handler_type=FSMAwareEventHandler
|
||||
)
|
||||
# Catches special commands
|
||||
commands_eh = eh_factory.build(TestCommandsEventHandler(
|
||||
commands_eh = eh_factory.build(TestCommandsHandler(
|
||||
bashrc=f'/home/{TAOENV.USER}/.bashrc'
|
||||
))
|
||||
|
||||
|
Reference in New Issue
Block a user