summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOlle Lundberg <geek@nerd.sh>2014-08-14 13:58:05 +0200
committerOlle Lundberg <geek@nerd.sh>2014-08-14 13:58:05 +0200
commite4e499fdf327a4f7db60bc9245bf9a8d6dc3da39 (patch)
tree1faf2a2d6645726fd539f6d9a4f5dde0be4cdb23
parent72c6b5ce3a49ec3c9cd68127091549c3fc4914cb (diff)
Whitespace fixes.
-rw-r--r--paramiko/channel.py112
1 files changed, 56 insertions, 56 deletions
diff --git a/paramiko/channel.py b/paramiko/channel.py
index 583809d5..164e9243 100644
--- a/paramiko/channel.py
+++ b/paramiko/channel.py
@@ -96,13 +96,13 @@ class Channel (object):
self.combine_stderr = False
self.exit_status = -1
self.origin_addr = None
-
+
def __del__(self):
try:
self.close()
except:
pass
-
+
def __repr__(self):
"""
Return a string representation of this object, for debugging.
@@ -136,7 +136,7 @@ class Channel (object):
:param int height: height (in characters) of the terminal screen
:param int width_pixels: width (in pixels) of the terminal screen
:param int height_pixels: height (in pixels) of the terminal screen
-
+
:raises SSHException:
if the request was rejected or the channel was closed
"""
@@ -162,14 +162,14 @@ class Channel (object):
Request an interactive shell session on this channel. If the server
allows it, the channel will then be directly connected to the stdin,
stdout, and stderr of the shell.
-
+
Normally you would call `get_pty` before this, in which case the
shell will operate through the pty, and the channel will be connected
to the stdin and stdout of the pty.
-
+
When the shell exits, the channel will be closed and can't be reused.
You must open a new channel if you wish to open another shell.
-
+
:raises SSHException: if the request was rejected or the channel was
closed
"""
@@ -189,7 +189,7 @@ class Channel (object):
Execute a command on the server. If the server allows it, the channel
will then be directly connected to the stdin, stdout, and stderr of
the command being executed.
-
+
When the command finishes executing, the channel will be closed and
can't be reused. You must open a new channel if you wish to execute
another command.
@@ -216,7 +216,7 @@ class Channel (object):
Request a subsystem on the server (for example, ``sftp``). If the
server allows it, the channel will then be directly connected to the
requested subsystem.
-
+
When the subsystem finishes, the channel will be closed and can't be
reused.
@@ -269,14 +269,14 @@ class Channel (object):
status. You may use this to poll the process status if you don't
want to block in `recv_exit_status`. Note that the server may not
return an exit status in some cases (like bad servers).
-
+
:return:
``True`` if `recv_exit_status` will return immediately, else ``False``.
.. versionadded:: 1.7.3
"""
return self.closed or self.status_event.isSet()
-
+
def recv_exit_status(self):
"""
Return the exit status from the process on the server. This is
@@ -284,9 +284,9 @@ class Channel (object):
If the command hasn't finished yet, this method will wait until
it does, or until the channel is closed. If no exit status is
provided by the server, -1 is returned.
-
+
:return: the exit code (as an `int`) of the process on the server.
-
+
.. versionadded:: 1.2
"""
self.status_event.wait()
@@ -299,9 +299,9 @@ class Channel (object):
really only makes sense in server mode.) Many clients expect to
get some sort of status code back from an executed command after
it completes.
-
+
:param int status: the exit code of the process
-
+
.. versionadded:: 1.2
"""
# in many cases, the channel will not still be open here.
@@ -313,32 +313,32 @@ class Channel (object):
m.add_boolean(False)
m.add_int(status)
self.transport._send_user_message(m)
-
+
def request_x11(self, screen_number=0, auth_protocol=None, auth_cookie=None,
single_connection=False, handler=None):
"""
Request an x11 session on this channel. If the server allows it,
further x11 requests can be made from the server to the client,
when an x11 application is run in a shell session.
-
+
From RFC4254::
It is RECOMMENDED that the 'x11 authentication cookie' that is
sent be a fake, random cookie, and that the cookie be checked and
replaced by the real cookie when a connection request is received.
-
+
If you omit the auth_cookie, a new secure random 128-bit value will be
generated, used, and returned. You will need to use this value to
verify incoming x11 requests and replace them with the actual local
x11 cookie (which requires some knoweldge of the x11 protocol).
-
+
If a handler is passed in, the handler is called from another thread
whenever a new x11 connection arrives. The default handler queues up
incoming x11 connections, which may be retrieved using
`.Transport.accept`. The handler's calling signature is::
-
+
handler(channel: Channel, (address: str, port: int))
-
+
:param int screen_number: the x11 screen number (0, 10, etc)
:param str auth_protocol:
the name of the X11 authentication method used; if none is given,
@@ -425,33 +425,33 @@ class Channel (object):
def get_id(self):
"""
Return the `int` ID # for this channel.
-
+
The channel ID is unique across a `.Transport` and usually a small
number. It's also the number passed to
`.ServerInterface.check_channel_request` when determining whether to
accept a channel request in server mode.
"""
return self.chanid
-
+
def set_combine_stderr(self, combine):
"""
Set whether stderr should be combined into stdout on this channel.
The default is ``False``, but in some cases it may be convenient to
have both streams combined.
-
+
If this is ``False``, and `exec_command` is called (or ``invoke_shell``
with no pty), output to stderr will not show up through the `recv`
and `recv_ready` calls. You will have to use `recv_stderr` and
`recv_stderr_ready` to get stderr output.
-
+
If this is ``True``, data will never show up via `recv_stderr` or
`recv_stderr_ready`.
-
+
:param bool combine:
``True`` if stderr output should be combined into stdout on this
channel.
:return: the previous setting (a `bool`).
-
+
.. versionadded:: 1.1
"""
data = bytes()
@@ -560,7 +560,7 @@ class Channel (object):
Returns true if data is buffered and ready to be read from this
channel. A ``False`` result does not mean that the channel has closed;
it means you may need to wait before more data arrives.
-
+
:return:
``True`` if a `recv` call on this channel would immediately return
at least one byte; ``False`` otherwise.
@@ -576,7 +576,7 @@ class Channel (object):
:param int nbytes: maximum number of bytes to read.
:return: received data, as a `str`
-
+
:raises socket.timeout:
if no data is ready before the timeout set by `settimeout`.
"""
@@ -602,11 +602,11 @@ class Channel (object):
channel's stderr stream. Only channels using `exec_command` or
`invoke_shell` without a pty will ever have data on the stderr
stream.
-
+
:return:
``True`` if a `recv_stderr` call on this channel would immediately
return at least one byte; ``False`` otherwise.
-
+
.. versionadded:: 1.1
"""
return self.in_stderr_buffer.read_ready()
@@ -622,17 +622,17 @@ class Channel (object):
:param int nbytes: maximum number of bytes to read.
:return: received data as a `str`
-
+
:raises socket.timeout: if no data is ready before the timeout set by
`settimeout`.
-
+
.. versionadded:: 1.1
"""
try:
out = self.in_stderr_buffer.read(nbytes, self.timeout)
except PipeTimeout:
raise socket.timeout()
-
+
ack = self._check_add_window(len(out))
# no need to hold the channel lock when sending this
if ack > 0:
@@ -648,11 +648,11 @@ class Channel (object):
"""
Returns true if data can be written to this channel without blocking.
This means the channel is either closed (so any write attempt would
- return immediately) or there is at least one byte of space in the
+ return immediately) or there is at least one byte of space in the
outbound buffer. If there is at least one byte of space in the
outbound buffer, a `send` call will succeed immediately and return
the number of bytes actually written.
-
+
:return:
``True`` if a `send` call on this channel would immediately succeed
or fail
@@ -664,7 +664,7 @@ class Channel (object):
return self.out_window_size > 0
finally:
self.lock.release()
-
+
def send(self, s):
"""
Send data to the channel. Returns the number of bytes sent, or 0 if
@@ -705,13 +705,13 @@ class Channel (object):
stream is closed. Applications are responsible for checking that all
data has been sent: if only some of the data was transmitted, the
application needs to attempt delivery of the remaining data.
-
+
:param str s: data to send.
:return: number of bytes actually sent, as an `int`.
-
+
:raises socket.timeout:
if no data could be sent before the timeout set by `settimeout`.
-
+
.. versionadded:: 1.1
"""
size = len(s)
@@ -745,7 +745,7 @@ class Channel (object):
if sending stalled for longer than the timeout set by `settimeout`.
:raises socket.error:
if an error occured before the entire string was sent.
-
+
.. note::
If the channel is closed while only part of the data hase been
sent, there is no way to determine how much data (if any) was sent.
@@ -765,14 +765,14 @@ class Channel (object):
results. Unlike `send_stderr`, this method continues to send data
from the given string until all data has been sent or an error occurs.
Nothing is returned.
-
+
:param str s: data to send to the client as "stderr" output.
-
+
:raises socket.timeout:
if sending stalled for longer than the timeout set by `settimeout`.
:raises socket.error:
if an error occured before the entire string was sent.
-
+
.. versionadded:: 1.1
"""
while s:
@@ -797,18 +797,18 @@ class Channel (object):
Return a file-like object associated with this channel's stderr
stream. Only channels using `exec_command` or `invoke_shell`
without a pty will ever have data on the stderr stream.
-
+
The optional ``mode`` and ``bufsize`` arguments are interpreted the
same way as by the built-in ``file()`` function in Python. For a
client, it only makes sense to open this file for reading. For a
server, it only makes sense to open this file for writing.
-
+
:return: `.ChannelFile` object which can be used for Python file I/O.
.. versionadded:: 1.1
"""
return ChannelStderrFile(*([self] + list(params)))
-
+
def fileno(self):
"""
Returns an OS-level file descriptor which can be used for polling, but
@@ -822,7 +822,7 @@ class Channel (object):
open at the same time.)
:return: an OS-level file descriptor (`int`)
-
+
.. warning::
This method causes channel reads to be slightly less efficient.
"""
@@ -861,7 +861,7 @@ class Channel (object):
self.lock.release()
if m is not None:
self.transport._send_user_message(m)
-
+
def shutdown_read(self):
"""
Shutdown the receiving side of this socket, closing the stream in
@@ -869,11 +869,11 @@ class Channel (object):
channel will fail instantly. This is a convenience method, equivalent
to ``shutdown(0)``, for people who don't make it a habit to
memorize unix constants from the 1970s.
-
+
.. versionadded:: 1.2
"""
self.shutdown(0)
-
+
def shutdown_write(self):
"""
Shutdown the sending side of this socket, closing the stream in
@@ -881,7 +881,7 @@ class Channel (object):
channel will fail instantly. This is a convenience method, equivalent
to ``shutdown(1)``, for people who don't make it a habit to
memorize unix constants from the 1970s.
-
+
.. versionadded:: 1.2
"""
self.shutdown(1)
@@ -899,14 +899,14 @@ class Channel (object):
self.in_window_threshold = window_size // 10
self.in_window_sofar = 0
self._log(DEBUG, 'Max packet in: %d bytes' % max_packet_size)
-
+
def _set_remote_channel(self, chanid, window_size, max_packet_size):
self.remote_chanid = chanid
self.out_window_size = window_size
self.out_max_packet_size = max(max_packet_size, MIN_PACKET_SIZE)
self.active = 1
self._log(DEBUG, 'Max packet out: %d bytes' % max_packet_size)
-
+
def _request_success(self, m):
self._log(DEBUG, 'Sesch channel %d request ok' % self.chanid)
self.event_ready = True
@@ -941,7 +941,7 @@ class Channel (object):
self._feed(s)
else:
self.in_stderr_buffer.feed(s)
-
+
def _window_adjust(self, m):
nbytes = m.get_int()
self.lock.acquire()
@@ -1183,7 +1183,7 @@ class Channel (object):
if self.ultra_debug:
self._log(DEBUG, 'window down to %d' % self.out_window_size)
return size
-
+
class ChannelFile (BufferedFile):
"""
@@ -1223,7 +1223,7 @@ class ChannelStderrFile (ChannelFile):
def _read(self, size):
return self.channel.recv_stderr(size)
-
+
def _write(self, data):
self.channel.sendall_stderr(data)
return len(data)