Update terminalManagement

This commit is contained in:
chrys87 2017-08-24 10:47:44 +02:00 committed by GitHub
parent 5f554792f1
commit 5c2357cc8a

View File

@ -39,13 +39,14 @@ def open_terminal(command="bash", columns=80, lines=25):
argv = shlex.split(command) argv = shlex.split(command)
env = dict(TERM="linux", LC_ALL=sys.stdout.encoding, env = dict(TERM="linux", LC_ALL=sys.stdout.encoding,
COLUMNS=str(columns), LINES=str(lines)) COLUMNS=str(columns), LINES=str(lines))
#env = os.environ.copy()
os.execvpe(argv[0], argv, env) os.execvpe(argv[0], argv, env)
# File-like object for I/O with the child process aka command. # File-like object for I/O with the child process aka command.
p_out = os.fdopen(master_fd, "w+b", 0) p_out = os.fdopen(master_fd, "w+b", 0)
return Terminal(columns, lines, p_out), p_pid, p_out return Terminal(columns, lines, p_out), p_pid, p_out
def HandleTerminal(): def HandleTerminal():
debug = False debug = True
running = True running = True
#attr = termios.tcgetattr(sys.stdin.fileno()) #attr = termios.tcgetattr(sys.stdin.fileno())
try: try:
@ -89,7 +90,9 @@ def HandleTerminal():
running = False running = False
break break
#msgBytes = os.read(sys.stdin.fileno(), 1) #msgBytes = os.read(sys.stdin.fileno(), 1)
print('1')
terminal.feed(msgBytes) terminal.feed(msgBytes)
print('2')
os.write(p_out.fileno(), msgBytes) os.write(p_out.fileno(), msgBytes)
if debug: if debug:
print('after stdin') print('after stdin')