From c7a8fd3925edf5864bd70c10655ce8157ce42ad4 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 21 Aug 2017 17:45:03 +0200 Subject: [PATCH] Update terminalManagement --- play zone/terminalManagement | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/play zone/terminalManagement b/play zone/terminalManagement index f524b927..94f879b6 100644 --- a/play zone/terminalManagement +++ b/play zone/terminalManagement @@ -56,3 +56,30 @@ convert_to_text(t.dump()) t.feed(b'ls\r') t.feed(o.read(10000)) convert_to_text(t.dump()) + + +def HandleTerminal(): + terminal, p_pid, p_out, master_fd = open_terminal() + while True: + try: + r, w, x = select.select([p_out, master_fd],[],[],500000) + if r == []: + continue + for fd in r: + print(fd,r) + msg = fd.read(65536) + if fd == p_out: + terminal.feed(msg) + master_fd.write(msg) + if fd == master_fd: + terminal.feed(msg) + p_out.write(msg + print(terminal.screen.display) + except Exception as e: # Process died? + print(e) + #finally: + # os.kill(p_pid, signal.SIGTERM) + # p_out.close() + +if __name__ == "__main__": + HandleTerminal()