aboutsummaryrefslogtreecommitdiff
path: root/paramiko/proxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'paramiko/proxy.py')
-rw-r--r--paramiko/proxy.py29
1 files changed, 11 insertions, 18 deletions
diff --git a/paramiko/proxy.py b/paramiko/proxy.py
index 3f5c8bb..8959b24 100644
--- a/paramiko/proxy.py
+++ b/paramiko/proxy.py
@@ -16,9 +16,6 @@
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-"""
-L{ProxyCommand}.
-"""
from datetime import datetime
import os
@@ -36,18 +33,17 @@ class ProxyCommand(object):
Wraps a subprocess running ProxyCommand-driven programs.
This class implements a the socket-like interface needed by the
- L{Transport} and L{Packetizer} classes. Using this class instead of a
+ `.Transport` and `.Packetizer` classes. Using this class instead of a
regular socket makes it possible to talk with a Popen'd command that will
proxy traffic between the client and a server hosted in another machine.
"""
def __init__(self, command_line):
"""
Create a new CommandProxy instance. The instance created by this
- class can be passed as an argument to the L{Transport} class.
+ class can be passed as an argument to the `.Transport` class.
- @param command_line: the command that should be executed and
- used as the proxy.
- @type command_line: str
+ :param str command_line:
+ the command that should be executed and used as the proxy.
"""
self.cmd = shlsplit(command_line)
self.process = Popen(self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
@@ -59,12 +55,11 @@ class ProxyCommand(object):
Write the content received from the SSH client to the standard
input of the forked command.
- @param content: string to be sent to the forked command
- @type content: str
+ :param str content: string to be sent to the forked command
"""
try:
self.process.stdin.write(content)
- except IOError, e:
+ except IOError as e:
# There was a problem with the child process. It probably
# died and we can't proceed. The best option here is to
# raise an exception informing the user that the informed
@@ -76,18 +71,16 @@ class ProxyCommand(object):
"""
Read from the standard output of the forked program.
- @param size: how many chars should be read
- @type size: int
+ :param int size: how many chars should be read
- @return: the length of the read content
- @rtype: int
+ :return: the length of the read content, as an `int`
"""
try:
start = datetime.now()
while len(self.buffer) < size:
if self.timeout is not None:
elapsed = (datetime.now() - start).microseconds
- timeout = self.timeout * 1000 * 1000 # to microseconds
+ timeout = self.timeout * 1000 * 1000 # to microseconds
if elapsed >= timeout:
raise socket.timeout()
r, w, x = select([self.process.stdout], [], [], 0.0)
@@ -101,8 +94,8 @@ class ProxyCommand(object):
self.buffer = []
return result
except socket.timeout:
- raise # socket.timeout is a subclass of IOError
- except IOError, e:
+ raise # socket.timeout is a subclass of IOError
+ except IOError as e:
raise ProxyCommandFailure(' '.join(self.cmd), e.strerror)
def close(self):