Commit a5044a34 by fwkz

minor refactor of ssh_interactive()

parent a58e1983
...@@ -446,23 +446,23 @@ def boolify(value): ...@@ -446,23 +446,23 @@ def boolify(value):
def ssh_interactive(ssh): def ssh_interactive(ssh):
chan = ssh.invoke_shell() chan = ssh.invoke_shell()
try: if os.name == 'posix':
import termios
import tty
posix_shell(chan) posix_shell(chan)
except: else:
windows_shell(chan) windows_shell(chan)
def posix_shell(chan): def posix_shell(chan):
import termios
import tty
oldtty = termios.tcgetattr(sys.stdin) oldtty = termios.tcgetattr(sys.stdin)
try: try:
tty.setraw(sys.stdin.fileno()) tty.setraw(sys.stdin.fileno())
tty.setcbreak(sys.stdin.fileno()) tty.setcbreak(sys.stdin.fileno())
chan.settimeout(0.0) chan.settimeout(0.0)
while(True): while True:
r, w, e = select.select([chan, sys.stdin], [], []) r, w, e = select.select([chan, sys.stdin], [], [])
if chan in r: if chan in r:
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment