Go to the latest version of this document.

# ``twisted`.`conch`.`endpoints`.`_CommandChannel``

class documentation

`class _CommandChannel(SSHChannel): (source)`

Constructor: `_CommandChannel(creator, command, protocolFactory, commandConnected)`

View In Hierarchy

A `_CommandChannel` executes a command in a session channel and connects its input and output to an `IProtocol` provider.

Method | `__init__` | No summary
Method | `channelOpen` | When the request to open a new channel to run this command in succeeds, issue an `"exec"` request to run the command.
Method | `closed` | When the channel closes, deliver disconnection notification to the protocol.
Method | `dataReceived` | When the command's stdout data arrives over the channel, deliver it to the protocol instance.
Method | `openFailed` | When the request to open a new channel to run this command in fails, fire the `commandConnected` deferred with a failure indicating that.
Method | `request_exit_signal` | When the server sends the command's exit status, record it for later delivery to the protocol.
Method | `request_exit_status` | When the server sends the command's exit status, record it for later delivery to the protocol.
Instance Variable | `name` | Undocumented
Method | `_execFailure` | When the request to execute the command in this channel fails, fire the `commandConnected` deferred with a failure indicating this.
Method | `_execSuccess` | When the request to execute the command in this channel succeeds, use `protocolFactory` to build a protocol to handle the command's input and output and connect the protocol to a transport representing those streams.
Class Variable | `_log` | Undocumented
Instance Variable | `_command` | See `__init__`
Instance Variable | `_commandConnected` | See `__init__`
Instance Variable | `_creator` | See `__init__`
Instance Variable | `_protocol` | An `IProtocol` provider created using `_protocolFactory` which is hooked up to the running command's input and output streams.
Instance Variable | `_protocolFactory` | See `__init__`
Instance Variable | `_reason` | Undocumented

Inherited from `SSHChannel`:

Method | `__bytes__` | Return a byte string representation of the channel
Method | `__str__` | Undocumented
Method | `addWindowBytes` | Called when bytes are added to the remote window. By default it clears the data buffers.
Method | `closeReceived` | Called when the other side has closed the channel.
Method | `eofReceived` | Called when the other side will send no more data.
Method | `extReceived` | Called when we receive extended data (usually standard error).
Method | `getHost` | See: `ITransport.getHost`
Method | `getPeer` | See: `ITransport.getPeer`
Method | `logPrefix` | Override this method to insert custom logging behavior. Its return value will be inserted in front of every line. It may be called more times than the number of output lines.
Method | `loseConnection` | Close the channel if there is no buferred data. Otherwise, note the request and return.
Method | `requestReceived` | Called when a request is sent to this channel. By default it delegates to self.request_<requestType>. If this function returns true, the request succeeded, otherwise it failed.
Method | `startWriting` | Called when the remote buffer has more room, as a hint to continue writing.
Method | `stopWriting` | Called when the remote buffer is full, as a hint to stop writing. This can be ignored, but it can be helpful.
Method | `write` | Write some data to the channel. If there is not enough remote window available, buffer until it is. Otherwise, split the data into packets of length remoteMaxPacket and send them.
Method | `writeExtended` | Send extended data to this channel. If there is not enough remote window available, buffer until there is. Otherwise, split the data into packets of length remoteMaxPacket and send them.
Method | `writeSequence` | Part of the Transport interface. Write a list of strings to the channel.
Instance Variable | `areWriting` | Undocumented
Instance Variable | `avatar` | an avatar for the logged-in user (if a server channel)
Instance Variable | `buf` | Undocumented
Instance Variable | `closing` | Undocumented
Instance Variable | `conn` | the connection this channel is multiplexed through.
Instance Variable | `data` | any data to send to the other side when the channel is requested.
Instance Variable | `extBuf` | Undocumented
Instance Variable | `id` | Undocumented
Instance Variable | `localClosed` | True if we aren't accepting more data.
Instance Variable | `localMaxPacket` | the maximum size of packet we will accept in bytes.
Instance Variable | `localWindowLeft` | how many bytes are left in the local window.
Instance Variable | `localWindowSize` | the maximum size of the local window in bytes.
Instance Variable | `remoteClosed` | True if the other side isn't accepting more data.
Instance Variable | `remoteMaxPacket` | the maximum size of a packet the remote side will accept in bytes.
Instance Variable | `remoteWindowLeft` | how many bytes are left in the remote window.
Instance Variable | `specificData` | Undocumented

def __init__(self, creator, command, protocolFactory, commandConnected): (source)
overrides `twisted.conch.ssh.channel.SSHChannel.__init__`

Parameters
creator:`_ISSHConnectionCreator` provider | The `_ISSHConnectionCreator` provider which was used to get the connection which this channel exists on.
command:`bytes` | The command to be executed.
protocolFactory | A client factory to use to build a `IProtocol` provider to use to associate with the running command.
commandConnected:`Deferred` | A `Deferred` to use to signal that execution of the command has failed or that it has succeeded and the command is now running.

def channelOpen(self, ignored): (source)
overrides `twisted.conch.ssh.channel.SSHChannel.channelOpen`

When the request to open a new channel to run this command in succeeds, issue an `"exec"` request to run the command.

def closed(self): (source)
overrides `twisted.conch.ssh.channel.SSHChannel.closed`

When the channel closes, deliver disconnection notification to the protocol.

def dataReceived(self, data): (source)
overrides `twisted.conch.ssh.channel.SSHChannel.dataReceived`

When the command's stdout data arrives over the channel, deliver it to the protocol instance.

Parameters
data:`bytes` | The bytes from the command's stdout.

def openFailed(self, reason): (source)
overrides `twisted.conch.ssh.channel.SSHChannel.openFailed`

When the request to open a new channel to run this command in fails, fire the `commandConnected` deferred with a failure indicating that.

def request_exit_signal(self, data): (source)

When the server sends the command's exit status, record it for later delivery to the protocol.

Parameters
data:`bytes` | The network-order four byte representation of the exit signal of the command.

def request_exit_status(self, data): (source)

When the server sends the command's exit status, record it for later delivery to the protocol.

Parameters
data:`bytes` | The network-order four byte representation of the exit status of the command.

name: `bytes` = (source)
overrides `twisted.conch.ssh.channel.SSHChannel.name`

Undocumented

def _execFailure(self, reason): (source)

When the request to execute the command in this channel fails, fire the `commandConnected` deferred with a failure indicating this.

Parameters
reason:`Failure` | The cause of the command execution failure.

def _execSuccess(self, ignored): (source)

When the request to execute the command in this channel succeeds, use `protocolFactory` to build a protocol to handle the command's input and output and connect the protocol to a transport representing those streams.

Also fire `commandConnected` with the created protocol after it is connected to its transport.

Parameters
ignored | The (ignored) result of the execute request

_log = (source)
overrides `twisted.conch.ssh.channel.SSHChannel._log`

Undocumented

_command = (source)

See `__init__`

_commandConnected = (source)

See `__init__`

_creator = (source)

See `__init__`

_protocol = (source)

An `IProtocol` provider created using `_protocolFactory` which is hooked up to the running command's input and output streams.

_protocolFactory = (source)

See `__init__`

_reason = (source)

Undocumented