home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / f / ftplib < prev    next >
Text File  |  1996-11-14  |  3KB  |  62 lines

  1. <TITLE>ftplib -- Python library reference</TITLE>
  2. Next: <A HREF="../g/gopherlib" TYPE="Next">gopherlib</A>  
  3. Prev: <A HREF="../h/httplib" TYPE="Prev">httplib</A>  
  4. Up: <A HREF="../i/internet_and_www" TYPE="Up">Internet and WWW</A>  
  5. Top: <A HREF="../t/top" TYPE="Top">Top</A>  
  6. <H1>10.4. Standard Module <CODE>ftplib</CODE></H1>
  7. This module defines the class <CODE>FTP</CODE> and a few related items.  The
  8. <CODE>FTP</CODE> class implements the client side of the FTP protocol.  You
  9. can use this to write Python programs that perform a variety of
  10. automated FTP jobs, such as mirroring other ftp servers.  It is also
  11. used by the module <CODE>urllib</CODE> to handle URLs that use FTP.  For
  12. more information on FTP (File Transfer Protocol), see Internet RFC
  13. 959.
  14. <P>
  15. Here's a sample session using the <CODE>ftplib</CODE> module:
  16. <P>
  17. <UL COMPACT><CODE>>>> from ftplib import FTP<P>
  18. >>> ftp = FTP('ftp.cwi.nl')   # connect to host, default port<P>
  19. >>> ftp.login()               # user anonymous, passwd user@hostname<P>
  20. >>> ftp.retrlines('LIST')     # list directory contents<P>
  21. total 24418<P>
  22. drwxrwsr-x   5 ftp-usr  pdmaint     1536 Mar 20 09:48 .<P>
  23. dr-xr-srwt 105 ftp-usr  pdmaint     1536 Mar 21 14:32 ..<P>
  24. -rw-r--r--   1 ftp-usr  pdmaint     5305 Mar 20 09:48 INDEX<P>
  25.  .<P>
  26.  .<P>
  27.  .<P>
  28. >>> ftp.quit()<P>
  29. </CODE></UL>
  30. The module defines the following items:
  31. <P>
  32. <DL><DT><B>FTP</B> ([<VAR>host</VAR>[, <VAR>user</VAR>, <VAR>passwd</VAR>, <VAR>acct</VAR>]]) -- function of module ftplib<DD>
  33. Return a new instance of the <CODE>FTP</CODE> class.  When
  34. <VAR>host</VAR> is given, the method call <CODE>connect(<VAR>host</VAR>)</CODE> is
  35. made.  When <VAR>user</VAR> is given, additionally the method call
  36. <CODE>login(<VAR>user</VAR>, <VAR>passwd</VAR>, <VAR>acct</VAR>)</CODE> is made (where
  37. <VAR>passwd</VAR> and <VAR>acct</VAR> default to the empty string when not given).
  38. </DL>
  39. <DL><DT><B>all_errors</B> -- data of module ftplib<DD>
  40. The set of all exceptions (as a tuple) that methods of <CODE>FTP</CODE>
  41. instances may raise as a result of problems with the FTP connection
  42. (as opposed to programming errors made by the caller).  This set
  43. includes the four exceptions listed below as well as
  44. <CODE>socket.error</CODE> and <CODE>IOError</CODE>.
  45. </DL>
  46. <DL><DT><B>error_reply</B> -- exception of module ftplib<DD>
  47. Exception raised when an unexpected reply is received from the server.
  48. </DL>
  49. <DL><DT><B>error_temp</B> -- exception of module ftplib<DD>
  50. Exception raised when an error code in the range 400--499 is received.
  51. </DL>
  52. <DL><DT><B>error_perm</B> -- exception of module ftplib<DD>
  53. Exception raised when an error code in the range 500--599 is received.
  54. </DL>
  55. <DL><DT><B>error_proto</B> -- exception of module ftplib<DD>
  56. Exception raised when a reply is received from the server that does
  57. not begin with a digit in the range 1--5.
  58. </DL>
  59. <H2>Menu</H2><DL COMPACT>
  60. <DT><A HREF="../f/ftp_objects" TYPE=Menu>FTP Objects</A>
  61. <DD></DL>
  62.