mirror of
				https://github.com/avatao-content/test-tutorial-framework
				synced 2025-11-04 02:42:56 +00:00 
			
		
		
		
	Simplify MessageSender, IDE and terminal handler
This commit is contained in:
		
				
					committed by
					
						
						therealkrispet
					
				
			
			
				
	
			
			
			
						parent
						
							a1ad0e6356
						
					
				
				
					commit
					e366a2652b
				
			@@ -15,7 +15,6 @@ ADD solvable/src/webservice/frontend-deps.tar ${TFW_WEBSERVICE_DIR}/static
 | 
			
		||||
 | 
			
		||||
# Create IDE directory, symlink server source and give proper permissions to AVATAO_USER
 | 
			
		||||
RUN mkdir -p ${TFW_IDE_WD}                                               &&\
 | 
			
		||||
    ln -s ${TFW_WEBSERVICE_DIR}/user_ops.py ${TFW_IDE_WD}                &&\
 | 
			
		||||
    chown -R ${AVATAO_USER}: "${TFW_IDE_WD}" "${TFW_WEBSERVICE_DIR}"     &&\
 | 
			
		||||
    chmod -R 755 "${TFW_IDE_WD}" "${TFW_WEBSERVICE_DIR}"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ class CenatorHandler:
 | 
			
		||||
    def handle_event(self, message, connector):  # pylint: disable=no-self-use
 | 
			
		||||
        command = message['value']
 | 
			
		||||
        LOG.debug('User executed command: "%s"', command)
 | 
			
		||||
        MessageSender(connector).send('JOHN CENA', f'You\'ve executed "{command}"')
 | 
			
		||||
        MessageSender(connector).send(f'You\'ve executed "{command}"', originator='JOHN CENA')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestCommandsHandler(TerminalCommandsHandler):
 | 
			
		||||
@@ -39,7 +39,7 @@ def messageFSMStepsHandler(message, connector):
 | 
			
		||||
    Receives a 'data' field from an fsm_update message as kwargs.
 | 
			
		||||
    """
 | 
			
		||||
    MessageSender(connector).send(
 | 
			
		||||
        'FSM info',
 | 
			
		||||
        f'FSM has stepped from state "{message["last_event"]["from_state"]}" '
 | 
			
		||||
        f'to state "{message["current_state"]}" in response to trigger "{message["last_event"]["trigger"]}"'
 | 
			
		||||
        f'to state "{message["current_state"]}" in response to trigger "{message["last_event"]["trigger"]}"',
 | 
			
		||||
        originator='FSM info'
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
@@ -40,15 +40,13 @@ def main():
 | 
			
		||||
    ))
 | 
			
		||||
    # Web IDE backend
 | 
			
		||||
    ide_eh = eh_factory.build(IdeHandler(
 | 
			
		||||
        allowed_directories=[TFWENV.IDE_WD, TFWENV.WEBSERVICE_DIR],
 | 
			
		||||
        directory=TFWENV.IDE_WD,
 | 
			
		||||
        exclude=['*.pyc']
 | 
			
		||||
        patterns=['/home/user/workdir/*', '/srv/webservice/user_ops.py']
 | 
			
		||||
    ))
 | 
			
		||||
    # Web shell backend
 | 
			
		||||
    terminal_eh = eh_factory.build(TerminalHandler(
 | 
			
		||||
        port=TFWENV.TERMINADO_PORT,
 | 
			
		||||
        user=TAOENV.USER,
 | 
			
		||||
        workind_directory=TFWENV.TERMINADO_WD,
 | 
			
		||||
        working_directory=TFWENV.TERMINADO_WD,
 | 
			
		||||
        histfile=TFWENV.HISTFILE
 | 
			
		||||
    ))
 | 
			
		||||
    # Handles 'deploy' button clicks
 | 
			
		||||
@@ -63,13 +61,13 @@ def main():
 | 
			
		||||
        log_tail=2000
 | 
			
		||||
    ))
 | 
			
		||||
    # Manages filesystem snapshots of directories
 | 
			
		||||
    snapshot_eh = eh_factory.build(SnapshotHandler(
 | 
			
		||||
        directories=[
 | 
			
		||||
            TFWENV.IDE_WD,
 | 
			
		||||
            TFWENV.WEBSERVICE_DIR
 | 
			
		||||
        ],
 | 
			
		||||
        snapshots_dir=TFWENV.SNAPSHOTS_DIR
 | 
			
		||||
    ))
 | 
			
		||||
    #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(FrontendHandler())
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user