Package twisted :: Package conch :: Module telnet :: Class Telnet
[show private | hide private]
[frames | no frames]

Class Telnet

BaseProtocol --+    
               |    
        Protocol --+
                   |
                  Telnet

Known Subclasses:
TelnetClientProtocol


Method Summary
  __init__(self)
  applicationDataReceived(self, bytes)
Called with application-level data.
  commandReceived(self, command, argument)
  connectionLost(self, reason)
  dataReceived(self, data)
Called whenever data is received.
  disableLocal(self, option)
  disableRemote(self, option)
  do(self, option)
  do_no_false(self, state, option)
  do_no_true(self, state, option)
  do_yes_false(self, state, option)
  do_yes_true(self, state, option)
  dont(self, option)
  dont_no_false(self, state, option)
  dont_no_true(self, state, option)
  dont_yes_false(self, state, option)
  dont_yes_true(self, state, option)
  enableLocal(self, option)
  enableRemote(self, option)
  getOptionState(self, opt)
  negotiate(self, bytes)
  requestNegotiation(self, about, bytes)
  telnet_DO(self, option)
  telnet_DONT(self, option)
  telnet_WILL(self, option)
  telnet_WONT(self, option)
  unhandledCommand(self, command, argument)
Called for commands for which no handler is installed.
  unhandledSubnegotiation(self, command, bytes)
Called for subnegotiations for which no handler is installed.
  will(self, option)
Indicate our willingness to enable an option.
  will_no_false(self, state, option)
  will_no_true(self, state, option)
  will_yes_false(self, state, option)
  will_yes_true(self, state, option)
  wont(self, option)
Indicate we are not willing to enable an option.
  wont_no_false(self, state, option)
  wont_no_true(self, state, option)
  wont_yes_false(self, state, option)
  wont_yes_true(self, state, option)
  _do(self, option)
  _dont(self, option)
  _will(self, option)
  _wont(self, option)
  _write(self, bytes)
Inherited from BaseProtocol: connectionMade, makeConnection

Instance Variable Summary
  commandMap: A mapping of bytes to callables.
  negotiationMap: A mapping of bytes to callables.
  options: A mapping of option bytes to their current state.
str state: A string indicating the current parse state.
  transport: This protocol's transport object.

Class Variable Summary
dict doMap = {('yes', False): <function do_yes_false at 0x39c...
dict dontMap = {('yes', False): <function dont_yes_false at 0...
dict willMap = {('yes', False): <function will_yes_false at 0...
dict wontMap = {('yes', False): <function wont_yes_false at 0...
classobj _OptionState = twisted.conch.telnet._OptionState
Inherited from Protocol: __implemented__, __provides__
Inherited from BaseProtocol: __providedBy__, connected

Method Details

applicationDataReceived(self, bytes)

Called with application-level data.

dataReceived(self, data)

Called whenever data is received.

Use this method to translate to a higher-level message. Usually, some callback will be made upon the receipt of each complete protocol message.
Parameters:
data - a string of indeterminate length. Please keep in mind that you will probably need to buffer some data, as partial (or multiple) protocol messages may be received! I recommend that unit tests for protocols call through to this method with differing chunk sizes, down to one byte at a time.
Overrides:
twisted.internet.protocol.Protocol.dataReceived (inherited documentation)

unhandledCommand(self, command, argument)

Called for commands for which no handler is installed.

unhandledSubnegotiation(self, command, bytes)

Called for subnegotiations for which no handler is installed.

will(self, option)

Indicate our willingness to enable an option.

wont(self, option)

Indicate we are not willing to enable an option.

Instance Variable Details

commandMap

A mapping of bytes to callables. When a telnet command is received, the command byte (the first byte after IAC) is looked up in this dictionary. If a callable is found, it is invoked with the argument of the command, or None if the command takes no argument. Values should be added to this dictionary if commands wish to be handled. By default, only WILL, WONT, DO, and DONT are handled. These should not be overridden, as this class handles them correctly and provides an API for interacting with them.

negotiationMap

A mapping of bytes to callables. When a subnegotiation command is received, the command byte (the first byte after SB) is looked up in this dictionary. If a callable is found, it is invoked with the argument of the subnegotiation. Values should be added to this dictionary if subnegotiations are to be handled. By default, no values are handled.

options

A mapping of option bytes to their current state. This state is likely of little use to user code. Changes should not be made to it.

state

A string indicating the current parse state. It can take on the values "data", "escaped", "command", "newline", "subnegotiation", and "subnegotiation-escaped". Changes should not be made to it.
Type:
str
Value:
'data'                                                                 

transport

This protocol's transport object.

Class Variable Details

doMap

Type:
dict
Value:
{('no', False): <function do_no_false at 0x39cf0f0>,
 ('no', True): <function do_no_true at 0x39cf130>,
 ('yes', False): <function do_yes_false at 0x39cf170>,
 ('yes', True): <function do_yes_true at 0x39cf1b0>}                   

dontMap

Type:
dict
Value:
{('no', False): <function dont_no_false at 0x39cf230>,
 ('no', True): <function dont_no_true at 0x39cf270>,
 ('yes', False): <function dont_yes_false at 0x39cf2b0>,
 ('yes', True): <function dont_yes_true at 0x39cf2f0>}                 

willMap

Type:
dict
Value:
{('no', False): <function will_no_false at 0x39c8e30>,
 ('no', True): <function will_no_true at 0x39c8e70>,
 ('yes', False): <function will_yes_false at 0x39c8eb0>,
 ('yes', True): <function will_yes_true at 0x39c8ef0>}                 

wontMap

Type:
dict
Value:
{('no', False): <function wont_no_false at 0x39c8f70>,
 ('no', True): <function wont_no_true at 0x39c8fb0>,
 ('yes', False): <function wont_yes_false at 0x39cf030>,
 ('yes', True): <function wont_yes_true at 0x39cf070>}                 

Generated by Epydoc 2.1 on Thu Aug 16 09:55:10 2007 http://epydoc.sf.net