mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-11-14 02:47:17 +00:00
Fix event handler types and sendmessage command
This commit is contained in:
parent
620f6aa643
commit
054d52b5fa
@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from ast import literal_eval
|
||||
from json import loads, JSONDecodeError
|
||||
|
||||
from tfw.components.frontend import MessageSender
|
||||
from tfw.components.terminal import TerminalCommandsHandler
|
||||
@ -21,16 +21,16 @@ class TestCommandsHandler(TerminalCommandsHandler):
|
||||
# pylint: disable=unused-argument,attribute-defined-outside-init,no-self-use
|
||||
def command_sendmessage(self, *args):
|
||||
if not args:
|
||||
message_template = """'{"key": "", "data": {"command": ""}}'"""
|
||||
message_template = """'{"key": ""}'"""
|
||||
TFWUplinkConnector().send_message({
|
||||
'key': 'shell',
|
||||
'data': {
|
||||
'command': 'write',
|
||||
'value': f'sendmessage {message_template}'
|
||||
}
|
||||
'key': 'terminal.write',
|
||||
'command': f'sendmessage {message_template}'
|
||||
})
|
||||
else:
|
||||
TFWUplinkConnector().send_message(literal_eval(args[0]))
|
||||
try:
|
||||
TFWUplinkConnector().send_message(loads(args[0]))
|
||||
except JSONDecodeError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', args[0])
|
||||
|
||||
|
||||
def messageFSMStepsHandler(message, connector):
|
||||
|
@ -37,7 +37,7 @@ def main():
|
||||
ide_eh = eh_factory.build(IdeHandler(
|
||||
patterns=['/home/user/workdir/*', '/srv/webservice/user_ops.py']
|
||||
), event_handler_type=ControlEventHandler)
|
||||
deploy_eh = eh_factory.build(DeployHandler(), event_handler_type=ControlEventHandler)
|
||||
deploy_eh = eh_factory.build(DeployHandler())
|
||||
# Web shell backend
|
||||
terminal_eh = eh_factory.build(TerminalHandler(
|
||||
port=TFWENV.TERMINADO_PORT,
|
||||
@ -59,11 +59,11 @@ def main():
|
||||
frontend_eh = eh_factory.build(FrontendProxyHandler(), event_handler_type=ControlEventHandler)
|
||||
message_queue_eh = eh_factory.build(MessageQueueHandler(25), event_handler_type=ControlEventHandler)
|
||||
# Writes live logs to console on frontend
|
||||
console_logs_eh = eh_factory.build(ConsoleLogsHandler(stream='stdout'), event_handler_type=ControlEventHandler)
|
||||
console_logs_eh = eh_factory.build(ConsoleLogsHandler(stream='stdout'))
|
||||
|
||||
# Replace these with your custom event handlers
|
||||
# Echoes executed commands to messages
|
||||
cenator_eh = eh_factory.build(CenatorHandler(), event_handler_type=ControlEventHandler)
|
||||
cenator_eh = eh_factory.build(CenatorHandler())
|
||||
# Echoes FSM steps
|
||||
message_fsm_steps_eh = eh_factory.build(
|
||||
messageFSMStepsHandler,
|
||||
@ -72,7 +72,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()
|
||||
|
Loading…
Reference in New Issue
Block a user