ftplib.FTP_TLS¶
-
class
ftplib.FTP_TLS(host='', user='', passwd='', acct='', keyfile=None, certfile=None, context=None, timeout=<object object>, source_address=None)[source]¶ A FTP subclass which adds TLS support to FTP as described in RFC-4217.
Connect as usual to port 21 implicitly securing the FTP control connection before authenticating.
Securing the data connection requires user to explicitly ask for it by calling prot_p() method.
Usage example: >>> from ftplib import FTP_TLS >>> ftps = FTP_TLS(‘ftp.python.org’) >>> ftps.login() # login anonymously previously securing control channel ‘230 Guest login ok, access restrictions apply.’ >>> ftps.prot_p() # switch to secure data connection ‘200 Protection level set to P’ >>> ftps.retrlines(‘LIST’) # list directory content securely total 9 drwxr-xr-x 8 root wheel 1024 Jan 3 1994 . drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .. drwxr-xr-x 2 root wheel 1024 Jan 3 1994 bin drwxr-xr-x 2 root wheel 1024 Jan 3 1994 etc d-wxrwxr-x 2 ftp wheel 1024 Sep 5 13:43 incoming drwxr-xr-x 2 root wheel 1024 Nov 17 1993 lib drwxr-xr-x 6 1094 wheel 1024 Sep 13 19:07 pub drwxr-xr-x 3 root wheel 1024 Jan 3 1994 usr -rw-r–r– 1 root root 312 Aug 1 1994 welcome.msg ‘226 Transfer complete.’ >>> ftps.quit() ‘221 Goodbye.’ >>>
Methods¶
__init__([host, user, passwd, acct, ...]) |
|
abort() |
Abort a file transfer. |
acct(password) |
Send new account name. |
auth() |
Set up secure control connection by using TLS/SSL. |
close() |
Close the connection without assuming anything about it. |
connect([host, port, timeout]) |
Connect to host. |
cwd(dirname) |
Change to a directory. |
debug(level) |
Set the debugging level. |
delete(filename) |
Delete a file. |
dir(*args) |
List a directory in long form. |
getline() |
|
getmultiline() |
|
getresp() |
|
getwelcome() |
Get the welcome message from the server. |
login([user, passwd, acct, secure]) |
|
makepasv() |
|
makeport() |
Create a new socket and send a PORT command for it. |
mkd(dirname) |
Make a directory, return its full pathname. |
nlst(*args) |
Return a list of files in a given directory (default the current). |
ntransfercmd(cmd[, rest]) |
|
prot_c() |
Set up clear text data connection. |
prot_p() |
Set up secure data connection. |
putcmd(line) |
|
putline(line) |
|
pwd() |
Return current working directory. |
quit() |
Quit, and close the connection. |
rename(fromname, toname) |
Rename a file. |
retrbinary(cmd, callback[, blocksize, rest]) |
|
retrlines(cmd[, callback]) |
|
rmd(dirname) |
Remove a directory. |
sanitize(s) |
|
sendcmd(cmd) |
Send a command and return the response. |
sendeprt(host, port) |
Send a EPRT command with the current host and the given port number. |
sendport(host, port) |
Send a PORT command with the current host and the given port number. |
set_debuglevel(level) |
Set the debugging level. |
set_pasv(val) |
Use passive or active mode for data transfers. |
size(filename) |
Retrieve the size of a file. |
storbinary(cmd, fp[, blocksize, callback, rest]) |
|
storlines(cmd, fp[, callback]) |
|
transfercmd(cmd[, rest]) |
Like ntransfercmd() but returns only the socket. |
voidcmd(cmd) |
Send a command and expect a response beginning with ‘2’. |
voidresp() |
Expect a response beginning with ‘2’. |
Attributes¶
debugging |
|
file |
|
host |
|
maxline |
|
passiveserver |
|
port |
|
sock |
|
ssl_version |
|
welcome |