Simplify MessageSender, IDE and terminal handler

This commit is contained in:
R. Richard 2019-08-07 10:02:16 +02:00 committed by therealkrispet
parent a1ad0e6356
commit e366a2652b
3 changed files with 12 additions and 15 deletions

View File

@ -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 # Create IDE directory, symlink server source and give proper permissions to AVATAO_USER
RUN mkdir -p ${TFW_IDE_WD} &&\ 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}" &&\ chown -R ${AVATAO_USER}: "${TFW_IDE_WD}" "${TFW_WEBSERVICE_DIR}" &&\
chmod -R 755 "${TFW_IDE_WD}" "${TFW_WEBSERVICE_DIR}" chmod -R 755 "${TFW_IDE_WD}" "${TFW_WEBSERVICE_DIR}"

View File

@ -14,7 +14,7 @@ class CenatorHandler:
def handle_event(self, message, connector): # pylint: disable=no-self-use def handle_event(self, message, connector): # pylint: disable=no-self-use
command = message['value'] command = message['value']
LOG.debug('User executed command: "%s"', command) 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): class TestCommandsHandler(TerminalCommandsHandler):
@ -39,7 +39,7 @@ def messageFSMStepsHandler(message, connector):
Receives a 'data' field from an fsm_update message as kwargs. Receives a 'data' field from an fsm_update message as kwargs.
""" """
MessageSender(connector).send( MessageSender(connector).send(
'FSM info',
f'FSM has stepped from state "{message["last_event"]["from_state"]}" ' 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'
) )

View File

@ -40,15 +40,13 @@ def main():
)) ))
# Web IDE backend # Web IDE backend
ide_eh = eh_factory.build(IdeHandler( ide_eh = eh_factory.build(IdeHandler(
allowed_directories=[TFWENV.IDE_WD, TFWENV.WEBSERVICE_DIR], patterns=['/home/user/workdir/*', '/srv/webservice/user_ops.py']
directory=TFWENV.IDE_WD,
exclude=['*.pyc']
)) ))
# Web shell backend # Web shell backend
terminal_eh = eh_factory.build(TerminalHandler( terminal_eh = eh_factory.build(TerminalHandler(
port=TFWENV.TERMINADO_PORT, port=TFWENV.TERMINADO_PORT,
user=TAOENV.USER, user=TAOENV.USER,
workind_directory=TFWENV.TERMINADO_WD, working_directory=TFWENV.TERMINADO_WD,
histfile=TFWENV.HISTFILE histfile=TFWENV.HISTFILE
)) ))
# Handles 'deploy' button clicks # Handles 'deploy' button clicks
@ -63,13 +61,13 @@ def main():
log_tail=2000 log_tail=2000
)) ))
# Manages filesystem snapshots of directories # Manages filesystem snapshots of directories
snapshot_eh = eh_factory.build(SnapshotHandler( #snapshot_eh = eh_factory.build(SnapshotHandler(
directories=[ # directories=[
TFWENV.IDE_WD, # TFWENV.IDE_WD,
TFWENV.WEBSERVICE_DIR # TFWENV.WEBSERVICE_DIR
], # ],
snapshots_dir=TFWENV.SNAPSHOTS_DIR # snapshots_dir=TFWENV.SNAPSHOTS_DIR
)) #))
# Proxies frontend API calls to frontend # Proxies frontend API calls to frontend
frontend_eh = eh_factory.build(FrontendHandler()) frontend_eh = eh_factory.build(FrontendHandler())