mirror of
				https://github.com/avatao-content/test-tutorial-framework
				synced 2025-11-04 12:52:55 +00:00 
			
		
		
		
	Introduce intent for TFW messages
This commit is contained in:
		
				
					committed by
					
						
						therealkrispet
					
				
			
			
				
	
			
			
			
						parent
						
							c972026385
						
					
				
				
					commit
					88e1818c86
				
			@@ -4,7 +4,7 @@ from functools import partial
 | 
			
		||||
from tornado.ioloop import IOLoop
 | 
			
		||||
 | 
			
		||||
from tfw.fsm import YamlFSM
 | 
			
		||||
from tfw.event_handlers import FSMAwareEventHandler
 | 
			
		||||
from tfw.event_handlers import FSMAwareEventHandler, ControlEventHandler
 | 
			
		||||
from tfw.components.ide import IdeHandler
 | 
			
		||||
from tfw.components.terminal import TerminalHandler
 | 
			
		||||
from tfw.components.frontend import FrontendProxyHandler, ConsoleLogsHandler
 | 
			
		||||
@@ -12,6 +12,7 @@ from tfw.components.process_management import ProcessHandler, ProcessLogHandler
 | 
			
		||||
from tfw.components.fsm import FSMHandler
 | 
			
		||||
from tfw.main import EventHandlerFactory, setup_logger, setup_signal_handlers
 | 
			
		||||
from tfw.config import TFWENV, TAOENV
 | 
			
		||||
from tfw.internals.networking import Intent
 | 
			
		||||
 | 
			
		||||
from custom_handlers import CenatorHandler, TestCommandsHandler, messageFSMStepsHandler
 | 
			
		||||
 | 
			
		||||
@@ -32,36 +33,36 @@ def main():
 | 
			
		||||
            {}  # jinja2 variables, empty dict enables jinja2 without any variables
 | 
			
		||||
        ),
 | 
			
		||||
        initial_trigger='step_1'
 | 
			
		||||
    ))
 | 
			
		||||
    ), event_handler_type=ControlEventHandler)
 | 
			
		||||
    # Web IDE backend
 | 
			
		||||
    ide_eh = eh_factory.build(IdeHandler(
 | 
			
		||||
        patterns=['/home/user/workdir/*', '/srv/webservice/user_ops.py']
 | 
			
		||||
    ))
 | 
			
		||||
    ), event_handler_type=ControlEventHandler)
 | 
			
		||||
    # Web shell backend
 | 
			
		||||
    terminal_eh = eh_factory.build(TerminalHandler(
 | 
			
		||||
        port=TFWENV.TERMINADO_PORT,
 | 
			
		||||
        user=TAOENV.USER,
 | 
			
		||||
        working_directory=TFWENV.TERMINADO_WD,
 | 
			
		||||
        histfile=TFWENV.HISTFILE
 | 
			
		||||
    ))
 | 
			
		||||
    ), event_handler_type=ControlEventHandler)
 | 
			
		||||
    # Handles 'deploy' button clicks
 | 
			
		||||
    processmanager_eh = eh_factory.build(ProcessHandler(
 | 
			
		||||
        supervisor_uri=TFWENV.SUPERVISOR_HTTP_URI
 | 
			
		||||
    ))
 | 
			
		||||
    ), event_handler_type=ControlEventHandler)
 | 
			
		||||
    # Sends live logs of webservice process to frontend
 | 
			
		||||
    logmonitor_eh = eh_factory.build(ProcessLogHandler(
 | 
			
		||||
        process_name='webservice',
 | 
			
		||||
        supervisor_uri=TFWENV.SUPERVISOR_HTTP_URI,
 | 
			
		||||
        log_tail=2000
 | 
			
		||||
    ))
 | 
			
		||||
    ), event_handler_type=ControlEventHandler)
 | 
			
		||||
    # Proxies frontend API calls to frontend
 | 
			
		||||
    frontend_eh = eh_factory.build(FrontendProxyHandler())
 | 
			
		||||
    frontend_eh = eh_factory.build(FrontendProxyHandler(), event_handler_type=ControlEventHandler)
 | 
			
		||||
    # Writes live logs to console on frontend
 | 
			
		||||
    console_logs_eh = eh_factory.build(ConsoleLogsHandler(stream='stdout'))
 | 
			
		||||
    console_logs_eh = eh_factory.build(ConsoleLogsHandler(stream='stdout'), event_handler_type=ControlEventHandler)
 | 
			
		||||
 | 
			
		||||
    # Replace these with your custom event handlers
 | 
			
		||||
    # Echoes executed commands to messages
 | 
			
		||||
    cenator_eh = eh_factory.build(CenatorHandler())
 | 
			
		||||
    cenator_eh = eh_factory.build(CenatorHandler(), event_handler_type=ControlEventHandler)
 | 
			
		||||
    # Echoes FSM steps
 | 
			
		||||
    message_fsm_steps_eh = eh_factory.build(
 | 
			
		||||
        messageFSMStepsHandler,
 | 
			
		||||
@@ -70,7 +71,7 @@ def main():
 | 
			
		||||
    # Catches special commands
 | 
			
		||||
    commands_eh = eh_factory.build(TestCommandsHandler(
 | 
			
		||||
        bashrc=f'/home/{TAOENV.USER}/.bashrc'
 | 
			
		||||
    ))
 | 
			
		||||
    ), event_handler_type=ControlEventHandler)
 | 
			
		||||
 | 
			
		||||
    setup_signal_handlers()
 | 
			
		||||
    IOLoop.current().start()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user