Home | Trees | Index | Help |
---|
Package paramiko :: Module channel :: Class Channel |
|
object
--+
|
Channel
A secure tunnel across an SSH Transport
. A Channel is meant to behave
like a socket, and has an API that should be indistinguishable from the
python socket API.
send
may block, unless you set a timeout.
This is exactly like a normal network socket, so it shouldn't be too
surprising.
Method Summary | |
---|---|
Create a new channel. | |
str |
Return a string representation of this object, for debugging. |
Close the channel. | |
bool |
Execute a command on the server. |
int |
Returns an OS-level file descriptor which can be used for polling and reading (but not for writing). |
int |
Return the ID # for this channel. |
str |
Get the name of this channel that was previously set by set_name . |
bool |
Request a pseudo-terminal from the server. |
Transport
|
Return the Transport associated with this channel. |
float |
Returns the timeout in seconds (as a float) associated with socket operations, or None if no timeout is set. |
bool |
Request an interactive shell session on this channel. |
bool |
Request a subsystem on the server (for example, sftp ). |
ChannelFile
|
Return a file-like object associated with this channel, without the non-portable side effects of fileno . |
ChannelFile
|
Return a file-like object associated with this channel's stderr stream. |
str |
Receive data from the channel. |
boolean |
Returns true if data is buffered and ready to be read from this channel. |
str |
Receive data from the channel's stderr stream. |
boolean |
Returns true if data is buffered and ready to be read from this channel's stderr stream. |
bool |
Resize the pseudo-terminal. |
int |
Send data to the channel. |
int |
Send data to the channel on the "stderr" stream. |
Send data to the channel, without allowing partial results. | |
Send data to the channel's "stderr" stream, without allowing partial results. | |
bool |
Set whether stderr should be combined into stdout on this channel. |
Set a name for this channel. | |
Set blocking or non-blocking mode of the channel: if blocking is 0, the channel is set to non-blocking mode;
otherwise it's set to blocking mode. | |
Set a timeout on blocking read/write operations. | |
Shut down one or both halves of the connection. | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Class Variable Summary | |
---|---|
int |
MIN_PACKET_SIZE = 1024 |
Method Details |
---|
__init__(self,
chanid)
Create a new channel. The channel is not associated with any
particular session or |
__repr__(self)
Return a string representation of this object, for debugging.
|
close(self)Close the channel. All future read/write operations on the channel will fail. The remote end will receive no more data (after queued data is flushed). Channels are automatically closed when they are garbage- collected, or when theirTransport is closed.
|
exec_command(self, command)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.
|
fileno(self)Returns an OS-level file descriptor which can be used for polling
and reading (but not for writing). This is primaily to allow
python's fileno is called on a channel, a pipe is
created to simulate real OS-level file descriptor (FD) behavior.
Because of this, two actual FDs are created -- this may be inefficient
if you plan to use many channels.
|
get_id(self)Return the ID # for this channel. The channel ID is unique across aTransport 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.
|
get_name(self)Get the name of this channel that was previously set byset_name .
|
get_pty(self, term='vt100', width=80, height=24)Request a pseudo-terminal from the server. This is usually used right after creating a client channel, to ask the server to provide some basic terminal semantics for a shell invoked withinvoke_shell . It isn't necessary (or
desirable) to call this method if you're going to exectue a single
command with exec_command .
|
get_transport(self)Return theTransport associated with this
channel.
|
gettimeout(self)Returns the timeout in seconds (as a float) associated with socket operations, orNone if no timeout is set. This reflects
the last call to setblocking or settimeout .
|
invoke_shell(self)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 callget_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.
|
invoke_subsystem(self, subsystem)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.
|
makefile(self, *params)Return a file-like object associated with this channel, without the non-portable side effects offileno . The optional mode
and bufsize arguments are interpreted the same way as by
the built-in file() function in python.
|
makefile_stderr(self, *params)Return a file-like object associated with this channel's stderr
stream. Only channels using 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.
|
recv(self, nbytes)Receive data from the channel. The return value is a string representing the data received. The maximum amount of data to be received at once is specified bynbytes . If a string of
length zero is returned, the channel stream has closed.
|
recv_ready(self)Returns true if data is buffered and ready to be read from this channel. AFalse result does not mean that the channel has
closed; it means you may need to wait before more data arrives.
|
recv_stderr(self, nbytes)Receive data from the channel's stderr stream. Only channels usingexec_command or invoke_shell without a pty will ever have
data on the stderr stream. The return value is a string representing
the data received. The maximum amount of data to be received at once is
specified by nbytes . If a string of length zero is
returned, the channel stream has closed.
|
recv_stderr_ready(self)Returns true if data is buffered and ready to be read from this channel's stderr stream. Only channels usingexec_command or invoke_shell without a pty will ever have
data on the stderr stream.
|
resize_pty(self, width=80, height=24)Resize the pseudo-terminal. This can be used to change the width and height of the terminal emulation created in a previousget_pty call.
|
send(self, s)Send data to the channel. Returns the number of bytes sent, or 0 if the channel 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.
|
send_stderr(self, s)Send data to the channel on the "stderr" stream. This is normally only used by servers to send output from shell commands -- clients won't use this. Returns the number of bytes sent, or 0 if the channel 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.
|
sendall(self, s)Send data to the channel, without allowing partial results. Unlikesend , this method continues to send data
from the given string until either all data has been sent or an error
occurs. Nothing is returned.
|
sendall_stderr(self, s)Send data to the channel's "stderr" stream, without allowing partial results. Unlikesend_stderr , this method continues to
send data from the given string until all data has been sent or an
error occurs. Nothing is returned.
|
set_combine_stderr(self, combine)Set whether stderr should be combined into stdout on this channel.
The default is If this is True , data will never show up via recv_stderr or recv_stderr_ready .
|
set_name(self, name)Set a name for this channel. Currently it's only used to set the name of the log level used for debugging. The name can be fetched with theget_name method.
|
setblocking(self, blocking)Set blocking or non-blocking mode of the channel: if
In non-blocking mode, if a chan.setblocking(0) is equivalent to
chan.settimeout(0) ; chan.setblocking(1) is
equivalent to chan.settimeout(None) .
|
settimeout(self, timeout)Set a timeout on blocking read/write operations. The
chan.settimeout(0.0) is equivalent to
chan.setblocking(0) ; chan.settimeout(None) is
equivalent to chan.setblocking(1) .
|
shutdown(self, how)Shut down one or both halves of the connection. Ifhow
is 0, further receives are disallowed. If how is 1,
further sends are disallowed. If how is 2, further sends
and receives are disallowed. This closes the stream in one or both
directions.
|
Class Variable Details |
---|
MIN_PACKET_SIZE
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Sun Dec 12 02:04:30 2004 | http://epydoc.sf.net |