summaryrefslogtreecommitdiff
path: root/paramiko/proxy.py
diff options
context:
space:
mode:
authorChris Rose <offline@offby1.net>2018-05-17 10:13:38 -0400
committerChris Rose <offline@offby1.net>2018-05-17 10:13:38 -0400
commit7f2c35052183b400827d9949a68b41c90f90a32d (patch)
treefea4a1ec04b7ee3ced14d61e8b6cf3f479e22704 /paramiko/proxy.py
parent52551321a2297bdb966869fa719e584c868dd857 (diff)
downloadparamiko-7f2c35052183b400827d9949a68b41c90f90a32d.tar.gz
Blacken Paramiko on 2.4
Diffstat (limited to 'paramiko/proxy.py')
-rw-r--r--paramiko/proxy.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/paramiko/proxy.py b/paramiko/proxy.py
index c4ec627c..d0ef8784 100644
--- a/paramiko/proxy.py
+++ b/paramiko/proxy.py
@@ -39,6 +39,7 @@ class ProxyCommand(ClosingContextManager):
Instances of this class may be used as context managers.
"""
+
def __init__(self, command_line):
"""
Create a new CommandProxy instance. The instance created by this
@@ -50,9 +51,11 @@ class ProxyCommand(ClosingContextManager):
# NOTE: subprocess import done lazily so platforms without it (e.g.
# GAE) can still import us during overall Paramiko load.
from subprocess import Popen, PIPE
+
self.cmd = shlsplit(command_line)
- self.process = Popen(self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE,
- bufsize=0)
+ self.process = Popen(
+ self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=0
+ )
self.timeout = None
def send(self, content):
@@ -69,7 +72,7 @@ class ProxyCommand(ClosingContextManager):
# died and we can't proceed. The best option here is to
# raise an exception informing the user that the informed
# ProxyCommand is not working.
- raise ProxyCommandFailure(' '.join(self.cmd), e.strerror)
+ raise ProxyCommandFailure(" ".join(self.cmd), e.strerror)
return len(content)
def recv(self, size):
@@ -81,7 +84,7 @@ class ProxyCommand(ClosingContextManager):
:return: the string of bytes read, which may be shorter than requested
"""
try:
- buffer = b''
+ buffer = b""
start = time.time()
while len(buffer) < size:
select_timeout = None
@@ -91,11 +94,11 @@ class ProxyCommand(ClosingContextManager):
raise socket.timeout()
select_timeout = self.timeout - elapsed
- r, w, x = select(
- [self.process.stdout], [], [], select_timeout)
+ r, w, x = select([self.process.stdout], [], [], select_timeout)
if r and r[0] == self.process.stdout:
buffer += os.read(
- self.process.stdout.fileno(), size - len(buffer))
+ self.process.stdout.fileno(), size - len(buffer)
+ )
return buffer
except socket.timeout:
if buffer:
@@ -103,7 +106,7 @@ class ProxyCommand(ClosingContextManager):
return buffer
raise # socket.timeout is a subclass of IOError
except IOError as e:
- raise ProxyCommandFailure(' '.join(self.cmd), e.strerror)
+ raise ProxyCommandFailure(" ".join(self.cmd), e.strerror)
def close(self):
os.kill(self.process.pid, signal.SIGTERM)