summaryrefslogtreecommitdiff
path: root/demos/interactive.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2018-05-29 15:18:24 -0700
committerJeff Forcier <jeff@bitprophet.org>2018-05-29 15:18:34 -0700
commitc091e756084ce017d8d872ffeaf95422f79140f1 (patch)
tree4c8c82399a6a21217f78ff36a90c3a355f6a0c23 /demos/interactive.py
parent0bf3fa458deffe1306f226a7257ceda927ca9e8e (diff)
downloadparamiko-c091e756084ce017d8d872ffeaf95422f79140f1.tar.gz
Blacken under black 18.5b0
Diffstat (limited to 'demos/interactive.py')
-rw-r--r--demos/interactive.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/demos/interactive.py b/demos/interactive.py
index 7138cd6c..037787c4 100644
--- a/demos/interactive.py
+++ b/demos/interactive.py
@@ -25,6 +25,7 @@ from paramiko.py3compat import u
try:
import termios
import tty
+
has_termios = True
except ImportError:
has_termios = False
@@ -39,7 +40,7 @@ def interactive_shell(chan):
def posix_shell(chan):
import select
-
+
oldtty = termios.tcgetattr(sys.stdin)
try:
tty.setraw(sys.stdin.fileno())
@@ -52,7 +53,7 @@ def posix_shell(chan):
try:
x = u(chan.recv(1024))
if len(x) == 0:
- sys.stdout.write('\r\n*** EOF\r\n')
+ sys.stdout.write("\r\n*** EOF\r\n")
break
sys.stdout.write(x)
sys.stdout.flush()
@@ -67,26 +68,28 @@ def posix_shell(chan):
finally:
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, oldtty)
-
+
# thanks to Mike Looijmans for this code
def windows_shell(chan):
import threading
- sys.stdout.write("Line-buffered terminal emulation. Press F6 or ^Z to send EOF.\r\n\r\n")
-
+ sys.stdout.write(
+ "Line-buffered terminal emulation. Press F6 or ^Z to send EOF.\r\n\r\n"
+ )
+
def writeall(sock):
while True:
data = sock.recv(256)
if not data:
- sys.stdout.write('\r\n*** EOF ***\r\n\r\n')
+ sys.stdout.write("\r\n*** EOF ***\r\n\r\n")
sys.stdout.flush()
break
sys.stdout.write(data)
sys.stdout.flush()
-
+
writer = threading.Thread(target=writeall, args=(chan,))
writer.start()
-
+
try:
while True:
d = sys.stdin.read(1)