twisted.protocols.ftp

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

## Module twisted.protocols.ftp

An FTP protocol implementation

Maintainer: Jonathan D. Simms

Classes
`DTP` | The Data Transfer Protocol for this FTP-PI instance all dtp_* methods return a deferred
`DTPFactory` |
`DTPFileSender` |
`FTP` | Protocol Interpreter for the File Transfer Protocol
`FTPAnonymousShell` | Only works on POSIX platforms at the moment.
`FTPClient` | A Twisted FTP Client
`FTPCommand` |
`FTPDataPortFactory` | Factory for data connections that use the PORT command
`FTPFactory` | A factory for producing ftp protocol instances
`FTPFileListProtocol` | Parser for standard FTP file listings
`FTPRealm` |
`IDTPFactory` | An interface for protocol.Factories
`IDTPParent` | An interface for protocols that wish to use a DTP sub-protocol and factory.
`IFTPShell` | An abstraction of the shell commands used by the FTP protocol for a given user account
`ProtocolWrapper` |
`SenderProtocol` |

Exceptions
`AnonUserDeniedError` | raised when an anonymous user issues a command that will alter the filesystem
`AuthorizationError` | raised when client authentication fails
`BadCmdSequenceError` | raised when a client sends a series of commands in an illogical sequence
`BadResponse` |
`BogusClientError` | thrown when a client other than the one we opened this DTP connection for attempts to connect, or a client attempts to get us to connect to an ip that differs from the one where the request came from
`ClientDisconnectError` |
`CmdArgSyntaxError` |
`CmdNotImplementedError` | raised when an unimplemented command is given to the server
`CmdNotImplementedForArgError` |
`CmdSyntaxError` |
`CommandFailed` |
`ConnectionLost` |
`DTPError` |
`FileNotFoundError` |
`FTPError` |
`FTPTimeoutError` |
`IsNotADirectoryError` | raised when RMD is called on a path that isn't a directory
`OperationFailedError` | raised when a command like rmd or mkdir fails for a reason other than permissions errors
`PathBelowTLDError` |
`PermissionDeniedError` |
`TLDNotSetInRealmError` | raised if the tld (root) directory for the FTPRealm was not set before requestAvatar was called
`UnexpectedResponse` |

Function Summary
| `_callWithDefault(default, _f, *_a, **_kw)`
| ``_getFPName`(fp)` returns a file object's name attr if it has one, otherwise it returns "<string>"
| ``_memberGIDs`(gid)` returns a list of all gid's that are a member of group with id
| ``_testPermissions`(uid, gid, spath, mode)` checks to see if uid has proper permissions to access path with mode
| `cleanPath(path)`
| `debugDeferred(self, *_)`
| ``decodeHostPort`(line)` Decode an FTP response specifying a host and port.
| ``parsePWDResponse`(response)` Returns the path from a response to a PWD command.

Variable Summary
`str` | `BAD_CMD_SEQ` = `'503'`
`str` | `CANT_OPEN_DATA_CNX` = `'425'`
`str` | `CLOSING_DATA_CNX` = `'226'`
`str` | `CMD_NOT_IMPLMNTD` = `'502'`
`str` | `CMD_NOT_IMPLMNTD_FOR_PARAM` = `'504'`
`str` | `CMD_NOT_IMPLMNTD_SUPERFLUOUS` = `'202'`
`str` | `CMD_OK` = `'200.1'`
`str` | `CNX_CLOSED_TXFR_ABORTED` = `'426'`
`str` | `DATA_CNX_ALREADY_OPEN_START_XFR` = `'125'`
`str` | `DATA_CNX_OPEN_NO_XFR_IN_PROGRESS` = `'225'`
`str` | `DIR_STATUS` = `'212'`
`str` | `ENDLN` = `'\r\n'`
`str` | `ENTERING_EPSV_MODE` = `'229'`
`str` | `ENTERING_PASV_MODE` = `'227'`
`str` | `ENTERING_PORT_MODE` = `'200.3'`
`str` | `EXCEEDED_STORAGE_ALLOC` = `'552'`
`str` | `FILE_STATUS` = `'213'`
`str` | `FILE_STATUS_OK_OPEN_DATA_CNX` = `'150'`
`str` | `FILENAME_NOT_ALLOWED` = `'553'`
`str` | `GOODBYE_MSG` = `'221'`
`str` | `HELP_MSG` = `'214'`
`str` | `NAME_SYS_TYPE` = `'215'`
`str` | `NEED_ACCT_FOR_LOGIN` = `'332'`
`str` | `NEED_ACCT_FOR_STOR` = `'532'`
`str` | `PAGE_TYPE_UNK` = `'551'`
`int` | `PASV` = 1
`int` | `PORT` = 2
`str` | `PWD_REPLY` = `'257'`
`str` | `REQ_ACTN_ABRTD_FILE_UNAVAIL` = `'450'`
`str` | `REQ_ACTN_ABRTD_INSUFF_STORAGE` = `'452'`
`str` | `REQ_ACTN_ABRTD_LOCAL_ERR` = `'451'`
`str` | `REQ_ACTN_NOT_TAKEN` = `'550.5'`
`str` | `REQ_FILE_ACTN_COMPLETED_OK` = `'250'`
`str` | `REQ_FILE_ACTN_PENDING_FURTHER_INFO` = `'350'`
`dict` | `RESPONSE` = `{'150': '150 File status okay; about to open ...`
`str` | `RESTART_MARKER_REPLY` = `'100'`
`str` | `SERVICE_READY_IN_N_MINUTES` = `'120'`
`str` | `SVC_CLOSING_CTRL_CNX` = `'221'`
`str` | `SVC_NOT_AVAIL_CLOSING_CTRL_CNX` = `'421.1'`
`str` | `SVC_READY_FOR_NEW_USER` = `'220.1'`
`str` | `SYNTAX_ERR` = `'500'`
`str` | `SYNTAX_ERR_IN_ARGS` = `'501'`
`str` | `SYS_STATUS_OR_HELP_REPLY` = `'211'`
`str` | `TOO_MANY_CONNECTIONS` = `'421.2'`
`str` | `TXFR_COMPLETE_OK` = `'226'`
`str` | `TYPE_SET_OK` = `'200.2'`
`str` | `WELCOME_MSG` = `'220.2'`

Function Details

### _getFPName(fp) returns a file object's name attr if it has one, otherwise it returns "<string>"

### _memberGIDs(gid) returns a list of all gid's that are a member of group with id

### _testPermissions(uid, gid, spath, mode='r') checks to see if uid has proper permissions to access path with mode Parameters: `uid` - numeric user id (type=int) `gid` - numeric group id (type=int) `spath` - the path on the server to test (type=string) `mode` - 'r' or 'w' (read or write) (type=string) Returns: a True if the uid can access path

### decodeHostPort(line) Decode an FTP response specifying a host and port. Returns: a 2-tuple of (host, port).

### parsePWDResponse(response) Returns the path from a response to a PWD command. Responses typically look like:
       257 "/home/andrew" is current directory.
For this example, I will return `'/home/andrew'`. If I can't find the path, I return `None`.

Variable Details

    ### BAD_CMD_SEQ Type: `str` Value:
        '503'

    ### CANT_OPEN_DATA_CNX Type: `str` Value:
        '425'

    ### CLOSING_DATA_CNX Type: `str` Value:
        '226'

    ### CMD_NOT_IMPLMNTD Type: `str` Value:
        '502'

    ### CMD_NOT_IMPLMNTD_FOR_PARAM Type: `str` Value:
        '504'

    ### CMD_NOT_IMPLMNTD_SUPERFLUOUS Type: `str` Value:
        '202'

    ### CMD_OK Type: `str` Value:
        '200.1'

    ### CNX_CLOSED_TXFR_ABORTED Type: `str` Value:
        '426'

    ### DATA_CNX_ALREADY_OPEN_START_XFR Type: `str` Value:
        '125'

    ### DATA_CNX_OPEN_NO_XFR_IN_PROGRESS Type: `str` Value:
        '225'

    ### DIR_STATUS Type: `str` Value:
        '212'

    ### ENDLN Type: `str` Value:
        '''\r
        '''

    ### ENTERING_EPSV_MODE Type: `str` Value:
        '229'

    ### ENTERING_PASV_MODE Type: `str` Value:
        '227'

    ### ENTERING_PORT_MODE Type: `str` Value:
        '200.3'

    ### EXCEEDED_STORAGE_ALLOC Type: `str` Value:
        '552'

    ### FILE_STATUS Type: `str` Value:
        '213'

    ### FILE_STATUS_OK_OPEN_DATA_CNX Type: `str` Value:
        '150'

    ### FILENAME_NOT_ALLOWED Type: `str` Value:
        '553'

    ### GOODBYE_MSG Type: `str` Value:
        '221'

    ### HELP_MSG Type: `str` Value:
        '214'

    ### NAME_SYS_TYPE Type: `str` Value:
        '215'

    ### NEED_ACCT_FOR_LOGIN Type: `str` Value:
        '332'

    ### NEED_ACCT_FOR_STOR Type: `str` Value:
        '532'

    ### PAGE_TYPE_UNK Type: `str` Value:
        '551'

    ### PASV Type: `int` Value:
        1

    ### PORT Type: `int` Value:
        2

    ### PWD_REPLY Type: `str` Value:
        '257'

    ### REQ_ACTN_ABRTD_FILE_UNAVAIL Type: `str` Value:
        '450'

    ### REQ_ACTN_ABRTD_INSUFF_STORAGE Type: `str` Value:
        '452'

    ### REQ_ACTN_ABRTD_LOCAL_ERR Type: `str` Value:
        '451'

    ### REQ_ACTN_NOT_TAKEN Type: `str` Value:
        '550.5'

    ### REQ_FILE_ACTN_COMPLETED_OK Type: `str` Value:
        '250'

    ### REQ_FILE_ACTN_PENDING_FURTHER_INFO Type: `str` Value:
        '350'

    ### RESPONSE Type: `dict` Value:
        {'100': '110 MARK yyyy-mmmm',
         '120': '120 service ready in %s minutes',
         '125': '125 Data connection already open, starting transfer',
         '150': '150 File status okay; about to open data connection.',
         '200.1': '200 Command OK',
         '200.2': '200 Type set to %s.',
         '200.3': '200 PORT OK',
         '202': '202 command not implemented, superfluous at this site',
        ...

    ### RESTART_MARKER_REPLY Type: `str` Value:
        '100'

    ### SERVICE_READY_IN_N_MINUTES Type: `str` Value:
        '120'

    ### SVC_CLOSING_CTRL_CNX Type: `str` Value:
        '221'

    ### SVC_NOT_AVAIL_CLOSING_CTRL_CNX Type: `str` Value:
        '421.1'

    ### SVC_READY_FOR_NEW_USER Type: `str` Value:
        '220.1'

    ### SYNTAX_ERR Type: `str` Value:
        '500'

    ### SYNTAX_ERR_IN_ARGS Type: `str` Value:
        '501'

    ### SYS_STATUS_OR_HELP_REPLY Type: `str` Value:
        '211'

    ### TOO_MANY_CONNECTIONS Type: `str` Value:
        '421.2'

    ### TXFR_COMPLETE_OK Type: `str` Value:
        '226'

    ### TYPE_SET_OK Type: `str` Value:
        '200.2'

    ### WELCOME_MSG Type: `str` Value:
        '220.2'

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