1998-08-10 19:42:37 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\section{\module{ftplib} ---
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-18 16:08:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         FTP protocol client}
							 | 
						
					
						
							
								
									
										
										
										
											1998-07-23 17:59:49 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-18 16:08:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\declaremodule{standard}{ftplib}
							 | 
						
					
						
							
								
									
										
										
										
											1998-07-23 17:59:49 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\modulesynopsis{FTP protocol client (requires sockets).}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2001-12-26 19:48:43 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\indexii{FTP}{protocol}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\index{FTP!\module{ftplib} (standard module)}
							 | 
						
					
						
							
								
									
										
										
										
											1995-02-28 17:14:32 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								This module defines the class \class{FTP} and a few related items.
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-18 16:08:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								The \class{FTP} class implements the client side of the FTP
							 | 
						
					
						
							
								
									
										
										
										
											2001-12-26 19:48:43 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								protocol.  You can use this to write Python
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-18 16:08:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								programs that perform a variety of automated FTP jobs, such as
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								mirroring other ftp servers.  It is also used by the module
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\refmodule{urllib} to handle URLs that use FTP.  For more information
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								on FTP (File Transfer Protocol), see Internet \rfc{959}.
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Here's a sample session using the \module{ftplib} module:
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-02-13 06:58:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{verbatim}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								>>> from ftplib import FTP
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								>>> ftp = FTP('ftp.cwi.nl')   # connect to host, default port
							 | 
						
					
						
							
								
									
										
										
										
											2001-12-28 20:54:28 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								>>> ftp.login()               # user anonymous, passwd anonymous@
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								>>> ftp.retrlines('LIST')     # list directory contents
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								total 24418
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								drwxrwsr-x   5 ftp-usr  pdmaint     1536 Mar 20 09:48 .
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								dr-xr-srwt 105 ftp-usr  pdmaint     1536 Mar 21 14:32 ..
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-rw-r--r--   1 ftp-usr  pdmaint     5305 Mar 20 09:48 INDEX
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 .
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 .
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 .
							 | 
						
					
						
							
								
									
										
										
										
											1998-08-07 17:30:49 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								>>> ftp.retrbinary('RETR README', open('README', 'wb').write)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								'226 Transfer complete.'
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								>>> ftp.quit()
							 | 
						
					
						
							
								
									
										
										
										
											1998-02-13 06:58:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{verbatim}
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								The module defines the following items:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{classdesc}{FTP}{\optional{host\optional{, user\optional{,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                       passwd\optional{, acct}}}}}
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Return a new instance of the \class{FTP} class.  When
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{host} is given, the method call \code{connect(\var{host})} is
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								made.  When \var{user} is given, additionally the method call
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\code{login(\var{user}, \var{passwd}, \var{acct})} is made (where
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\var{passwd} and \var{acct} default to the empty string when not given).
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{classdesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{datadesc}{all_errors}
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								The set of all exceptions (as a tuple) that methods of \class{FTP}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								instances may raise as a result of problems with the FTP connection
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								(as opposed to programming errors made by the caller).  This set
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								includes the four exceptions listed below as well as
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\exception{socket.error} and \exception{IOError}.
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{datadesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{excdesc}{error_reply}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Exception raised when an unexpected reply is received from the server.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{excdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{excdesc}{error_temp}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Exception raised when an error code in the range 400--499 is received.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{excdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{excdesc}{error_perm}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Exception raised when an error code in the range 500--599 is received.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{excdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{excdesc}{error_proto}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Exception raised when a reply is received from the server that does
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								not begin with a digit in the range 1--5.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{excdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-25 05:04:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{seealso}
							 | 
						
					
						
							
								
									
										
										
										
											1999-05-11 15:14:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  \seemodule{netrc}{Parser for the \file{.netrc} file format.  The file
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    \file{.netrc} is typically used by FTP clients to
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    load user authentication information before prompting
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    the user.}
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-25 05:04:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  \seetext{The file \file{Tools/scripts/ftpmirror.py}\index{ftpmirror.py}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								           in the Python source distribution is a script that can mirror
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								           FTP sites, or portions thereof, using the \module{ftplib} module.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								           It can be used as an extended example that applies this module.}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{seealso}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-18 16:08:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\subsection{FTP Objects \label{ftp-objects}}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1999-05-17 16:35:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Several methods are available in two flavors: one for handling text
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								files and another for binary files.  These are named for the command
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								which is used followed by \samp{lines} for the text version or
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\samp{binary} for the binary version.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\class{FTP} instances have the following methods:
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{set_debuglevel}{level}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Set the instance's debugging level.  This controls the amount of
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								debugging output printed.  The default, \code{0}, produces no
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								debugging output.  A value of \code{1} produces a moderate amount of
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								debugging output, generally a single line per request.  A value of
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\code{2} or higher produces the maximum amount of debugging output,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								logging each line sent and received on the control connection.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{connect}{host\optional{, port}}
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Connect to the given host and port.  The default port number is \code{21}, as
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								specified by the FTP protocol specification.  It is rarely needed to
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								specify a different port number.  This function should be called only
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								once for each instance; it should not be called at all if a host was
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								given when the instance was created.  All other methods can only be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								used after a connection has been made.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{getwelcome}{}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Return the welcome message sent by the server in reply to the initial
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								connection.  (This message sometimes contains disclaimers or help
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								information that may be relevant to the user.)
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{login}{\optional{user\optional{, passwd\optional{, acct}}}}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Log in as the given \var{user}.  The \var{passwd} and \var{acct}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								parameters are optional and default to the empty string.  If no
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{user} is specified, it defaults to \code{'anonymous'}.  If
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-18 16:08:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{user} is \code{'anonymous'}, the default \var{passwd} is
							 | 
						
					
						
							
								
									
										
										
										
											2001-12-28 20:54:28 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\code{'anonymous@'}.  This function should be called only
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								once for each instance, after a connection has been established; it
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								should not be called at all if a host and user were given when the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								instance was created.  Most FTP commands are only allowed after the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								client has logged in.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{abort}{}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Abort a file transfer that is in progress.  Using this does not always
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								work, but it's worth a try.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{sendcmd}{command}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Send a simple command string to the server and return the response
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								string.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{voidcmd}{command}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Send a simple command string to the server and handle the response.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Return nothing if a response code in the range 200--299 is received.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Raise an exception otherwise.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2000-09-01 06:32:32 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{retrbinary}{command,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    callback\optional{, maxblocksize\optional{, rest}}}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Retrieve a file in binary transfer mode.  \var{command} should be an
							 | 
						
					
						
							
								
									
										
										
										
											2001-07-06 19:28:48 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								appropriate \samp{RETR} command: \code{'RETR \var{filename}'}.
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								The \var{callback} function is called for each block of data received,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								with a single string argument giving the data block.
							 | 
						
					
						
							
								
									
										
										
										
											1997-12-03 19:34:14 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								The optional \var{maxblocksize} argument specifies the maximum chunk size to
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								read on the low-level socket object created to do the actual transfer
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								(which will also be the largest size of the data blocks passed to
							 | 
						
					
						
							
								
									
										
										
										
											2000-09-01 06:32:32 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{callback}).  A reasonable default is chosen. \var{rest} means the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								same thing as in the \method{transfercmd()} method.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{retrlines}{command\optional{, callback}}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Retrieve a file or directory listing in \ASCII{} transfer mode.
							 | 
						
					
						
							
								
									
										
										
										
											1996-12-13 22:04:31 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{command} should be an appropriate \samp{RETR} command (see
							 | 
						
					
						
							
								
									
										
										
										
											2003-05-10 03:35:37 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\method{retrbinary()}) or a \samp{LIST} command (usually just the string
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\code{'LIST'}).  The \var{callback} function is called for each line,
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								with the trailing CRLF stripped.  The default \var{callback} prints
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								the line to \code{sys.stdout}.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-18 16:08:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{set_pasv}{boolean}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Enable ``passive'' mode if \var{boolean} is true, other disable
							 | 
						
					
						
							
								
									
										
										
										
											2001-01-15 16:37:05 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								passive mode.  (In Python 2.0 and before, passive mode was off by
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								default; in Python 2.1 and later, it is on by default.)
							 | 
						
					
						
							
								
									
										
										
										
											1999-03-18 16:08:54 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2001-02-15 13:53:40 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{storbinary}{command, file\optional{, blocksize}}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Store a file in binary transfer mode.  \var{command} should be an
							 | 
						
					
						
							
								
									
										
										
										
											2001-07-06 19:28:48 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								appropriate \samp{STOR} command: \code{"STOR \var{filename}"}.
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{file} is an open file object which is read until \EOF{} using its
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\method{read()} method in blocks of size \var{blocksize} to provide the
							 | 
						
					
						
							
								
									
										
										
										
											2001-02-15 13:53:40 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								data to be stored.  The \var{blocksize} argument defaults to 8192.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\versionchanged[default for \var{blocksize} added]{2.1}
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{storlines}{command, file}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Store a file in \ASCII{} transfer mode.  \var{command} should be an
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-12 06:04:53 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								appropriate \samp{STOR} command (see \method{storbinary()}).  Lines are
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								read until \EOF{} from the open file object \var{file} using its
							 | 
						
					
						
							
								
									
										
										
										
											1999-07-20 13:21:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\method{readline()} method to provide the data to be stored.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2000-09-01 06:32:32 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{transfercmd}{cmd\optional{, rest}}
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Initiate a transfer over the data connection.  If the transfer is
							 | 
						
					
						
							
								
									
										
										
										
											2001-08-04 22:22:45 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								active, send a \samp{EPRT} or  \samp{PORT} command and the transfer command specified
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								by \var{cmd}, and accept the connection.  If the server is passive,
							 | 
						
					
						
							
								
									
										
										
										
											2001-08-04 22:22:45 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								send a \samp{EPSV} or \samp{PASV} command, connect to it, and start the transfer
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								command.  Either way, return the socket for the connection.
							 | 
						
					
						
							
								
									
										
										
										
											2000-09-01 06:32:32 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								If optional \var{rest} is given, a \samp{REST} command is
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								sent to the server, passing \var{rest} as an argument.  \var{rest} is
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								usually a byte offset into the requested file, telling the server to
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								restart sending the file's bytes at the requested offset, skipping
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								over the initial bytes.  Note however that RFC
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								959 requires only that \var{rest} be a string containing characters
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								in the printable range from ASCII code 33 to ASCII code 126.  The
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\method{transfercmd()} method, therefore, converts
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\var{rest} to a string, but no check is
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								performed on the string's contents.  If the server does
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								not recognize the \samp{REST} command, an
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\exception{error_reply} exception will be raised.  If this happens,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								simply call \method{transfercmd()} without a \var{rest} argument.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2000-09-01 06:32:32 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{ntransfercmd}{cmd\optional{, rest}}
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Like \method{transfercmd()}, but returns a tuple of the data
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								connection and the expected size of the data.  If the expected size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								could not be computed, \code{None} will be returned as the expected
							 | 
						
					
						
							
								
									
										
										
										
											2000-09-01 06:32:32 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								size.  \var{cmd} and \var{rest} means the same thing as in
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\method{transfercmd()}.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{nlst}{argument\optional{, \ldots}}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Return a list of files as returned by the \samp{NLST} command.  The
							 | 
						
					
						
							
								
									
										
										
										
											1996-12-13 22:04:31 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								optional \var{argument} is a directory to list (default is the current
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								server directory).  Multiple arguments can be used to pass
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								non-standard options to the \samp{NLST} command.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{dir}{argument\optional{, \ldots}}
							 | 
						
					
						
							
								
									
										
										
										
											1999-07-07 13:36:22 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Produce a directory listing as returned by the \samp{LIST} command,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								printing it to standard output.  The optional \var{argument} is a
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								directory to list (default is the current server directory).  Multiple
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								arguments can be used to pass non-standard options to the \samp{LIST}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								command.  If the last argument is a function, it is used as a
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\var{callback} function as for \method{retrlines()}; the default
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								prints to \code{sys.stdout}.  This method returns \code{None}.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{rename}{fromname, toname}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Rename file \var{fromname} on the server to \var{toname}.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{delete}{filename}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Remove the file named \var{filename} from the server.  If successful,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								returns the text of the response, otherwise raises
							 | 
						
					
						
							
								
									
										
										
										
											1999-04-22 16:15:34 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\exception{error_perm} on permission errors or
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\exception{error_reply} on other errors.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{cwd}{pathname}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Set the current directory on the server.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{mkd}{pathname}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Create a new directory on the server.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{pwd}{}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Return the pathname of the current directory on the server.
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-27 14:54:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{rmd}{dirname}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Remove the directory named \var{dirname} on the server.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{size}{filename}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Request the size of the file named \var{filename} on the server.  On
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								success, the size of the file is returned as an integer, otherwise
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\code{None} is returned.  Note that the \samp{SIZE} command is not 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								standardized, but is supported by many common server implementations.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{quit}{}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Send a \samp{QUIT} command to the server and close the connection.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								This is the ``polite'' way to close a connection, but it may raise an
							 | 
						
					
						
							
								
									
										
										
										
											1999-04-22 16:15:34 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								exception of the server reponds with an error to the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\samp{QUIT} command.  This implies a call to the \method{close()}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								method which renders the \class{FTP} instance useless for subsequent
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								calls (see below).
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{methoddesc}{close}{}
							 | 
						
					
						
							
								
									
										
										
										
											1995-03-22 15:48:46 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Close the connection unilaterally.  This should not be applied to an
							 | 
						
					
						
							
								
									
										
										
										
											2003-05-10 03:35:37 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								already closed connection such as after a successful call to
							 | 
						
					
						
							
								
									
										
										
										
											1998-08-07 17:36:59 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\method{quit()}.  After this call the \class{FTP} instance should not
							 | 
						
					
						
							
								
									
										
										
										
											2001-07-06 19:28:48 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								be used any more (after a call to \method{close()} or
							 | 
						
					
						
							
								
									
										
										
										
											2000-07-16 19:01:10 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\method{quit()} you cannot reopen the connection by issuing another
							 | 
						
					
						
							
								
									
										
										
										
											1998-08-07 17:36:59 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\method{login()} method).
							 | 
						
					
						
							
								
									
										
										
										
											1998-04-04 07:15:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\end{methoddesc}
							 |