diff --git a/lib/tfw/builtins/__init__.py b/lib/tfw/builtins/__init__.py index c8ab18b..d276619 100644 --- a/lib/tfw/builtins/__init__.py +++ b/lib/tfw/builtins/__init__.py @@ -8,5 +8,6 @@ from .log_monitoring_event_handler import LogMonitoringEventHandler from .pipe_io_event_handler import PipeIOEventHandlerBase, PipeIOEventHandler from .pipe_io_event_handler import TransformerPipeIOEventHandler, CommandEventHandler from .process_managing_event_handler import ProcessManagingEventHandler +from .terminal_commands_event_handler import TerminalCommandsEventHandler from .terminal_event_handler import TerminalEventHandler from .tfw_server_connector import TFWServerUplinkConnector, TFWServerConnector diff --git a/lib/tfw/builtins/terminal_commands_event_handler.py b/lib/tfw/builtins/terminal_commands_event_handler.py new file mode 100644 index 0000000..0385f0b --- /dev/null +++ b/lib/tfw/builtins/terminal_commands_event_handler.py @@ -0,0 +1,14 @@ +from tfw.components import TerminalCommands +from tfw.networking import Scope + +from .event_handler import EventHandler + + +class TerminalCommandsEventHandler(EventHandler, TerminalCommands): + def __init__(self, key, scope=Scope.ZMQ, bashrc=None): + EventHandler.__init__(self, key, scope) + TerminalCommands.__init__(self, bashrc) + + def handle_event(self, message): + command = message['value'] + self.callback(command)