# eric6.E5Network.E5Ftp

Module implementing an extension to the Python FTP class to support FTP proxies.

### Global Attributes

None

### Classes

E5Ftp | Class implementing an extension to the Python FTP class to support FTP proxies.
E5FtpProxyError | Class to signal an error related to proxy configuration.
E5FtpProxyType | Class defining the supported FTP proxy types.

### Functions

None

## E5Ftp

Class implementing an extension to the Python FTP class to support FTP proxies.

### Derived from

ftplib.FTP

### Class Attributes

None

### Class Methods

None

### Methods

E5Ftp | Constructor
connect | Public method to connect to the given FTP server.
login | Public method to login to the FTP server.
setProxy | Public method to set the proxy configuration.
setProxyAuthentication | Public method to set the proxy authentication info.

### Static Methods

None

#### E5Ftp (Constructor)

E5Ftp(host="", user="", password="", acct="", proxyType=E5FtpProxyType.NoProxy, proxyHost="", proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="", proxyAccount="", timeout=_GLOBAL_DEFAULT_TIMEOUT)

Constructor

host
  name of the FTP host (string)
user
  user name for login to FTP host (string)
password
  password for login to FTP host (string)
acct
  account for login to FTP host (string)
proxyType
  type of the FTP proxy (integer 0 to 8)
proxyHost
  name of the FTP proxy (string)
proxyPort
  port of the FTP proxy (integer)
proxyUser
  user name for login to the proxy (string)
proxyPassword
  password for login to the proxy (string)
proxyAccount
  accounting info for the proxy (string)
timeout
  timeout in seconds for blocking operations (integer)

#### E5Ftp.connect

connect(host="", port=0, timeout=-999)

Public method to connect to the given FTP server.

This extended method connects to the proxy instead of the given host, if a proxy is to be used. It throws an exception, if the proxy data is incomplete.

host
  name of the FTP host (string)
port
  port of the FTP host (integer)
timeout
  timeout in seconds for blocking operations (integer)

Returns:
  welcome message of the server (string)

Raises E5FtpProxyError:
  raised to indicate a proxy related issue

#### E5Ftp.login

login(user="", password="", acct="")

Public method to login to the FTP server.

This extended method respects the FTP proxy configuration. There are many different FTP proxy products available. But unfortunately there is no standard for how o traverse a FTP proxy. The lis below shows the sequence of commands used.

user | Username for remote host
pass | Password for remote host
pruser | Username for FTP proxy
prpass | Password for FTP proxy
remote.host | Hostname of the remote FTP server

E5FtpProxyType.NoProxy:
  USER user
  PASS pass
E5FtpProxyType.NonAuthorizing:
  USER user@remote.host
  PASS pass
E5FtpProxyType.UserAtServer:
  USER pruser
  PASS prpass
  USER user@remote.host
  PASS pass
E5FtpProxyType.Site:
  USER pruser
  PASS prpass
  SITE remote.site
  USER user
  PASS pass
E5FtpProxyType.Open:
  USER pruser
  PASS prpass
  OPEN remote.site
  USER user
  PASS pass
E5FtpProxyType.UserAtProxyuserAtServer:
  USER user@pruser@remote.host
  PASS pass@prpass
E5FtpProxyType.ProxyuserAtServer:
  USER pruser@remote.host
  PASS prpass
  USER user
  PASS pass
E5FtpProxyType.AuthResp:
  USER user@remote.host
  PASS pass
  AUTH pruser
  RESP prpass
E5FtpProxyType.Bluecoat:
  USER user@remote.host pruser
  PASS pass
  ACCT prpass

user
  username for the remote host (string)
password
  password for the remote host (string)
acct
  accounting information for the remote host (string)

Returns:
  response sent by the remote host (string)

Raises E5FtpProxyError:
  raised to indicate a proxy related issue
Raises ftplib.error_reply:
  raised to indicate an FTP error reply

#### E5Ftp.setProxy

setProxy(proxyType=E5FtpProxyType.NoProxy, proxyHost="", proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="", proxyAccount="")

Public method to set the proxy configuration.

proxyType
  type of the FTP proxy (integer 0 to 8)
proxyHost
  name of the FTP proxy (string)
proxyPort
  port of the FTP proxy (integer)
proxyUser
  user name for login to the proxy (string)
proxyPassword
  password for login to the proxy (string)
proxyAccount
  accounting info for the proxy (string)

#### E5Ftp.setProxyAuthentication

setProxyAuthentication(proxyUser="", proxyPassword="", proxyAccount="")

Public method to set the proxy authentication info.

proxyUser
  user name for login to the proxy (string)
proxyPassword
  password for login to the proxy (string)
proxyAccount
  accounting info for the proxy (string)

Up

## E5FtpProxyError

Class to signal an error related to proxy configuration.

The error message starts with a three digit error code followed by a space and the error string. Supported error codes are:

- 910: proxy error; the second number gives the category of the proxy error. The original response from the proxy is appended in the next line.
- 930: proxy error; the second number gives the category of the proxy error. The original response from the proxy is appended in the next line.
- 940: proxy error; the second number gives the category of the proxy error. The original response from the proxy is appended in the next line.
- 950: proxy error; the second number gives the category of the proxy error. The original response from the proxy is appended in the next line.
- 990: proxy usage is enabled but no proxy host given
- 991: proxy usage is enabled but no proxy user given
- 992: proxy usage is enabled but no proxy password given

### Derived from

ftplib.Error

### Class Attributes

None

### Class Methods

None

### Methods

None

### Static Methods

None

Up

## E5FtpProxyType

Class defining the supported FTP proxy types.

### Derived from

object

### Class Attributes

AuthResp
Bluecoat
NoProxy
NonAuthorizing
Open
ProxyuserAtServer
Site
UserAtProxyuserAtServer
UserAtServer

### Class Methods

None

### Methods

None

### Static Methods

None

Up