From e366a2652ba35a0f838b4e4327dbe4119179c706 Mon Sep 17 00:00:00 2001 From: "R. Richard" Date: Wed, 7 Aug 2019 10:02:16 +0200 Subject: [PATCH] Simplify MessageSender, IDE and terminal handler --- solvable/Dockerfile | 1 - solvable/src/custom_handlers.py | 6 +++--- solvable/src/event_handler_main.py | 20 +++++++++----------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/solvable/Dockerfile b/solvable/Dockerfile index d61c83a..2e82771 100644 --- a/solvable/Dockerfile +++ b/solvable/Dockerfile @@ -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}" diff --git a/solvable/src/custom_handlers.py b/solvable/src/custom_handlers.py index 67e48d2..bf34752 100644 --- a/solvable/src/custom_handlers.py +++ b/solvable/src/custom_handlers.py @@ -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' ) diff --git a/solvable/src/event_handler_main.py b/solvable/src/event_handler_main.py index bc44e16..6c00040 100644 --- a/solvable/src/event_handler_main.py +++ b/solvable/src/event_handler_main.py @@ -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())