Implement simple pty writing API

This commit is contained in:
Kristóf Tóth 2018-03-03 14:14:44 +01:00
parent c4c07a4c85
commit 4873bbf421

View File

@ -10,9 +10,13 @@ class TerminadoEventHandler(TriggerlessEventHandler):
super().__init__(key)
self.working_directory = tfwenv.TERMINADO_DIR
self.terminado_server = TerminadoMiniServer('/terminal', tfwenv.TERMINADO_PORT, tfwenv.TERMINADO_WD, ['bash'])
self.commands = {'write': self.write}
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
log.debug('TerminadoEventHandler received event: {}'.format(data_json))
data = data_json['data']
self.commands[data['command']](data)
def write(self, data):
self.terminado_server.pty.write(data['shellcmd'])