baseimage-tutorial-framework/lib/tfw/components/terminado_event_handler.py
2018-03-06 13:27:32 +01:00

19 lines
785 B
Python

from tfw.components.terminado_mini_server import TerminadoMiniServer
from tfw.event_handler_base import TriggerlessEventHandler
from tfw.config import tfwenv
from tfw.config.logs import logging
log = logging.getLogger(__name__)
class TerminadoEventHandler(TriggerlessEventHandler):
def __init__(self, key):
super().__init__(key)
self.working_directory = tfwenv.TERMINADO_DIR
self.terminado_server = TerminadoMiniServer('/terminal', tfwenv.TERMINADO_PORT, tfwenv.TERMINADO_WD, ['bash'])
self.terminado_server.listen()
def handle_event(self, key, data_json):
log.debug('TerminadoEventHandler received event for key {}'.format(key))
self.terminado_server.pty.write('echo cica\n')
# TODO: design & implement pty.write API