diff --git a/lib/tfw/components/terminado_event_handler.py b/lib/tfw/components/terminado_event_handler.py index 723bcfd..eb14431 100644 --- a/lib/tfw/components/terminado_event_handler.py +++ b/lib/tfw/components/terminado_event_handler.py @@ -1,5 +1,4 @@ from tfw.components.terminado_mini_server import TerminadoMiniServer -from tfw.components.history_monitor import BashMonitor from tfw.event_handler_base import TriggerlessEventHandler from tfw.config import TFWENV from tfw.config.logs import logging @@ -8,14 +7,15 @@ LOG = logging.getLogger(__name__) class TerminadoEventHandler(TriggerlessEventHandler): - def __init__(self, key): + def __init__(self, key, monitor): super().__init__(key) self.working_directory = TFWENV.TERMINADO_DIR - self._historymonitor = BashMonitor(TFWENV.HISTFILE) + self._historymonitor = monitor self.terminado_server = TerminadoMiniServer('/terminal', TFWENV.TERMINADO_PORT, TFWENV.TERMINADO_WD, ['bash']) self.commands = {'write': self.write, 'read': self.read} - self._historymonitor.watch() + if self._historymonitor: + self._historymonitor.watch() self.terminado_server.listen() @property @@ -35,8 +35,10 @@ class TerminadoEventHandler(TriggerlessEventHandler): def read(self, data): data['count'] = int(data.get('count', 1)) - data['history'] = self.historymonitor.history[-data['count']:] + if self.historymonitor: + data['history'] = self.historymonitor.history[-data['count']:] return data def cleanup(self): - self.historymonitor.stop() + if self.historymonitor: + self.historymonitor.stop()