mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-25 22:01:31 +00:00
Refactor pty resetting logic to TerminadoMiniServer
This commit is contained in:
parent
e20a5dab23
commit
1165fa4ec9
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user