Refactor pty resetting logic to TerminadoMiniServer

This commit is contained in:
Kristóf Tóth 2018-03-06 16:15:04 +01:00
parent e20a5dab23
commit 1165fa4ec9
2 changed files with 7 additions and 8 deletions

View File

@ -13,8 +13,7 @@ class TerminadoEventHandler(TriggerlessEventHandler):
self._historymonitor = HistoryMonitor(tfwenv.HISTFILE)
self.terminado_server = TerminadoMiniServer('/terminal', tfwenv.TERMINADO_PORT, tfwenv.TERMINADO_WD, ['bash'])
self.commands = {'write': self.write,
'read': self.read,
'resetshell': self.resetshell}
'read': self.read}
self._historymonitor.watch()
self.terminado_server.listen()
@ -36,9 +35,5 @@ class TerminadoEventHandler(TriggerlessEventHandler):
data['history'] = self.historymonitor.history[-data['count']:]
return data
def resetshell(self, data):
self.terminado_server.term_manager.terminal = None
self.terminado_server.term_manager.get_terminal()
def cleanup(self):
self.historymonitor.stop()

View File

@ -15,7 +15,7 @@ class TerminadoMiniServer:
self.application = Application(
[(
url,
TerminadoMiniServer.CORSTermSocket,
TerminadoMiniServer.ResetterTermSocket,
{'term_manager': self._term_manager}
)]
)
@ -28,10 +28,14 @@ class TerminadoMiniServer:
def pty(self):
return self.term_manager.terminal.ptyproc
class CORSTermSocket(TermSocket):
class ResetterTermSocket(TermSocket):
def check_origin(self, origin):
return True
def on_close(self):
self.term_manager.terminal = None
self.term_manager.get_terminal()
def listen(self):
self.application.listen(self.port)