Package twisted :: Package protocols :: Module ftp :: Class FTP
[frames | no frames]

Class FTP

BaseProtocol --+        
               |        
        Protocol --+    
                   |    
        LineReceiver --+
                       |
              object --+
                       |
        TimeoutMixin --+
                       |
                      FTP


Protocol Interpreter for the File Transfer Protocol
Method Summary
  __testingautologin(self)
  _cbAnonLogin(self, (interface, avatar, logout))
sets up anonymous login avatar
  _cbDTPCommand(self)
called back when any DTP command has completed successfully
  _cbLogin(self, (interface, avatar, logout))
sets up authorized user login avatar
  _createDTP(self)
  _doDTPCommand(self, cmd, *arg)
  _ebDTP(self, error)
  _ebLogin(self, failure)
  _unblock(self, *_)
  cleanupDTP(self)
call when DTP connection exits
  connectionLost(self, reason)
  connectionMade(self)
Called when a connection is made.
  decodeHostPort(self, line)
Decode an FTP response specifying a host and port.
  finishedFileTransfer(self, *arg)
called back when a file transfer has been completed by the dtp
  ftp_CDUP(self)
  ftp_CWD(self, params)
  ftp_LIST(self, params)
This command causes a list to be sent from the server to the passive DTP.
  ftp_MDTM(self, params)
  ftp_MODE(self, params)
  ftp_PASS(self, params)
Authorize the USER and the submitted password from the rfc: The argument field is a Telnet string specifying the user's password.
  ftp_PASV(self)
Request for a passive connection reply is in format 227 =h1,h2,h3,h4,p1,p2 from the rfc: This command requests the server-DTP to "listen" on a data port (which is not its default data port) and to wait for a connection rather than initiate one upon receipt of a transfer command.
  ftp_PORT(self, params)
  ftp_PWD(self, params)
Print working directory command
  ftp_QUIT(self, params)
  ftp_RETR(self, params)
  ftp_SIZE(self, params)
  ftp_STRU(self, params)
  ftp_SYST(self, params)
  ftp_TYPE(self, params)
  ftp_USER(self, params)
Get the login name, and reset the session PASS is expected to follow from the rfc: The argument field is a Telnet string identifying the user.
  lineReceived(self, line)
Process the input from the client
  processCommand(self, cmd, *args)
  reply(self, key, s)
format a RESPONSE and send it out over the wire
  setTimeout(self, seconds)
  timeoutConnection(self)
Called when the connection times out.
    Inherited from object
  __init__(...)
  __delattr__(...)
  __getattribute__(...)
  __hash__(...)
  __reduce__(...)
  __repr__(...)
  __setattr__(...)
  __str__(...)
    Inherited from LineReceiver
  clearLineBuffer(self)
Clear buffered data.
  dataReceived(self, data)
Protocol.dataReceived.
  lineLengthExceeded(self, line)
Called when the maximum line length has been reached.
  rawDataReceived(self, data)
Override this for when raw data is received.
  sendLine(self, line)
Sends a line to the other end of the connection.
  setLineMode(self, extra)
Sets the line-mode of this receiver.
  setRawMode(self)
Sets the raw mode of this receiver.
    Inherited from Protocol
  connectionFailed(self)
(Deprecated)
    Inherited from BaseProtocol
  makeConnection(self, transport)
Make a connection to a transport and a server.
    Inherited from TimeoutMixin
  resetTimeout(self)
Reset the timeout count down
    Inherited from type
  __new__(...)

Instance Variable Summary
int binary: The transfer mode.
NoneType blocked: Command queue for command pipelining
NoneType dtpFactory: Generates a single DTP for this session
NoneType dtpHostPort: cluient (address, port) to connect to on a PORT command
NoneType dtpInetPort: dtpPort.getHost()
NoneType dtpPort: Port returned from listenTCP
NoneType dtpTxfrMode: The current mode -- PASV or PORT
NoneType peerHost: The (type, ip, port) of the client
NoneType shell: The connected avatar
NoneType user: The username of the connected client

Class Variable Summary
tuple __implements__ = (<class 'twisted.protocols.ftp.IDTPPare...
list blockingCommands = ['RETR', 'STOR', 'LIST', 'PORT']
NoneType dtpInstance = None                                                                  
int dtpTimeout = 10                                                                    
int instanceNum = 0                                                                     
NoneType portal = None                                                                  
SRE_Pattern reTelnetChars = (\\x[0-9a-f]{2})+
    Inherited from LineReceiver
str _LineReceiver__buffer = ''
str delimiter: The line-ending delimiter to use.
int line_mode = 1                                                                     
int MAX_LENGTH: The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped).
    Inherited from BaseProtocol
int connected = 0                                                                     
NoneType transport = None                                                                  
    Inherited from TimeoutMixin
NoneType _TimeoutMixin__lastReceived = None                                                                  
NoneType _TimeoutMixin__timeoutCall = None                                                                  
NoneType timeOut: The number of seconds after which to timeout the connection.

Method Details

_cbAnonLogin(self, (interface, avatar, logout))

sets up anonymous login avatar

_cbDTPCommand(self)

called back when any DTP command has completed successfully

_cbLogin(self, (interface, avatar, logout))

sets up authorized user login avatar

cleanupDTP(self)

call when DTP connection exits

connectionMade(self)

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
Overrides:
twisted.internet.protocol.BaseProtocol.connectionMade (inherited documentation)

decodeHostPort(self, line)

Decode an FTP response specifying a host and port.

see RFC sec. 4.1.2 "PASV"
Returns:
a 2-tuple of (host, port).

finishedFileTransfer(self, *arg)

called back when a file transfer has been completed by the dtp

ftp_LIST(self, params='')

This command causes a list to be sent from the server to the passive DTP. If the pathname specifies a directory or other group of files, the server should transfer a list of files in the specified directory. If the pathname specifies a file then the server should send current information on the file. A null argument implies the user's current working or default directory.

ftp_PASS(self, params='')

Authorize the USER and the submitted password

from the rfc:
    The argument field is a Telnet string specifying the user's
    password.  This command must be immediately preceded by the
    user name command, and, for some sites, completes the user's
    identification for access control.

ftp_PASV(self)

Request for a passive connection

reply is in format 227 =h1,h2,h3,h4,p1,p2

from the rfc:
    This command requests the server-DTP to "listen" on a data
    port (which is not its default data port) and to wait for a
    connection rather than initiate one upon receipt of a
    transfer command.  The response to this command includes the
    host and port address this server is listening on.

ftp_PWD(self, params='')

Print working directory command

ftp_USER(self, params)

Get the login name, and reset the session
PASS is expected to follow

from the rfc:
    The argument field is a Telnet string identifying the user.
    The user identification is that which is required by the
    server for access to its file system.  This command will
    normally be the first command transmitted by the user after
    the control connections are made

    This has the effect of flushing any user, password, and account
    information already supplied and beginning the login sequence
    again.  All transfer parameters are unchanged and any file transfer
    in progress is completed under the old access control parameters.

lineReceived(self, line)

Process the input from the client
Overrides:
twisted.protocols.basic.LineReceiver.lineReceived

reply(self, key, s='')

format a RESPONSE and send it out over the wire

timeoutConnection(self)

Called when the connection times out. Override to define behavior other than dropping the connection.
Overrides:
twisted.protocols.policies.TimeoutMixin.timeoutConnection (inherited documentation)

Instance Variable Details

binary

The transfer mode. If false, ASCII.
Type:
int
Value:
1                                                                     

blocked

Command queue for command pipelining
Type:
NoneType
Value:
None                                                                  

dtpFactory

Generates a single DTP for this session
Type:
NoneType
Value:
None                                                                  

dtpHostPort

cluient (address, port) to connect to on a PORT command
Type:
NoneType
Value:
None                                                                  

dtpInetPort

dtpPort.getHost()
Type:
NoneType
Value:
None                                                                  

dtpPort

Port returned from listenTCP
Type:
NoneType
Value:
None                                                                  

dtpTxfrMode

The current mode -- PASV or PORT
Type:
NoneType
Value:
None                                                                  

peerHost

The (type, ip, port) of the client
Type:
NoneType
Value:
None                                                                  

shell

The connected avatar
Type:
NoneType
Value:
None                                                                  

user

The username of the connected client
Type:
NoneType
Value:
None                                                                  

Class Variable Details

__implements__

Type:
tuple
Value:
(<class 'twisted.protocols.ftp.IDTPParent'>,
 <class twisted.internet.interfaces.IProtocol at 0x8278f0c>)           

blockingCommands

Type:
list
Value:
['RETR', 'STOR', 'LIST', 'PORT']                                       

dtpInstance

Type:
NoneType
Value:
None                                                                  

dtpTimeout

Type:
int
Value:
10                                                                    

instanceNum

Type:
int
Value:
0                                                                     

portal

Type:
NoneType
Value:
None                                                                  

reTelnetChars

Type:
SRE_Pattern
Value:
(\\x[0-9a-f]{2})+                                                      

Generated by Epydoc 2.0 on Sat May 15 20:07:58 2004 http://epydoc.sf.net