Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / module-ftplib.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-gopherlib.html" />
13<link rel="prev" href="module-httplib.html" />
14<link rel="parent" href="internet.html" />
15<link rel="next" href="ftp-objects.html" />
16<meta name='aesop' content='information' />
17<title>11.7 ftplib -- FTP protocol client</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="11.6.3 Examples"
25 href="httplib-examples.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
28 href="internet.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="11.7.1 FTP Objects"
31 href="ftp-objects.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="httplib-examples.html">11.6.3 Examples</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="ftp-objects.html">11.7.1 FTP Objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0013700000000000000000">
5611.7 <tt class="module">ftplib</tt> --
57 FTP protocol client</A>
58</H1>
59
60<P>
61<A NAME="module-ftplib"></A>
62
63<P>
64<a id='l2h-3333' xml:id='l2h-3333'></a><a id='l2h-3341' xml:id='l2h-3341'></a>
65
66<P>
67This module defines the class <tt class="class">FTP</tt> and a few related items.
68The <tt class="class">FTP</tt> class implements the client side of the FTP
69protocol. You can use this to write Python
70programs that perform a variety of automated FTP jobs, such as
71mirroring other ftp servers. It is also used by the module
72<tt class="module"><a href="module-urllib.html">urllib</a></tt> to handle URLs that use FTP. For more information
73on FTP (File Transfer Protocol), see Internet <a class="rfc" id='rfcref-90129' xml:id='rfcref-90129'
74href="http://www.faqs.org/rfcs/rfc959.html">RFC 959</a>.
75
76<P>
77Here's a sample session using the <tt class="module">ftplib</tt> module:
78
79<P>
80<div class="verbatim"><pre>
81&gt;&gt;&gt; from ftplib import FTP
82&gt;&gt;&gt; ftp = FTP('ftp.cwi.nl') # connect to host, default port
83&gt;&gt;&gt; ftp.login() # user anonymous, passwd anonymous@
84&gt;&gt;&gt; ftp.retrlines('LIST') # list directory contents
85total 24418
86drwxrwsr-x 5 ftp-usr pdmaint 1536 Mar 20 09:48 .
87dr-xr-srwt 105 ftp-usr pdmaint 1536 Mar 21 14:32 ..
88-rw-r--r-- 1 ftp-usr pdmaint 5305 Mar 20 09:48 INDEX
89 .
90 .
91 .
92&gt;&gt;&gt; ftp.retrbinary('RETR README', open('README', 'wb').write)
93'226 Transfer complete.'
94&gt;&gt;&gt; ftp.quit()
95</pre></div>
96
97<P>
98The module defines the following items:
99
100<P>
101<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
102 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-3334' xml:id='l2h-3334' class="class">FTP</tt></b>(</nobr></td>
103 <td><var></var><big>[</big><var>host</var><big>[</big><var>, user</var><big>[</big><var>,
104 passwd</var><big>[</big><var>, acct</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
105<dd>
106Return a new instance of the <tt class="class">FTP</tt> class. When
107<var>host</var> is given, the method call <code>connect(<var>host</var>)</code> is
108made. When <var>user</var> is given, additionally the method call
109<code>login(<var>user</var>, <var>passwd</var>, <var>acct</var>)</code> is made (where
110<var>passwd</var> and <var>acct</var> default to the empty string when not given).
111</dl>
112
113<P>
114<dl><dt><b><tt id='l2h-3335' xml:id='l2h-3335'>all_errors</tt></b></dt>
115<dd>
116The set of all exceptions (as a tuple) that methods of <tt class="class">FTP</tt>
117instances may raise as a result of problems with the FTP connection
118(as opposed to programming errors made by the caller). This set
119includes the four exceptions listed below as well as
120<tt class="exception">socket.error</tt> and <tt class="exception">IOError</tt>.
121</dd></dl>
122
123<P>
124<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3336' xml:id='l2h-3336' class="exception">error_reply</tt></b></dt>
125<dd>
126Exception raised when an unexpected reply is received from the server.
127</dd></dl>
128
129<P>
130<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3337' xml:id='l2h-3337' class="exception">error_temp</tt></b></dt>
131<dd>
132Exception raised when an error code in the range 400-499 is received.
133</dd></dl>
134
135<P>
136<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3338' xml:id='l2h-3338' class="exception">error_perm</tt></b></dt>
137<dd>
138Exception raised when an error code in the range 500-599 is received.
139</dd></dl>
140
141<P>
142<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3339' xml:id='l2h-3339' class="exception">error_proto</tt></b></dt>
143<dd>
144Exception raised when a reply is received from the server that does
145not begin with a digit in the range 1-5.
146</dd></dl>
147
148<P>
149<div class="seealso">
150 <p class="heading">See Also:</p>
151
152 <dl compact="compact" class="seemodule">
153 <dt>Module <b><tt class="module"><a href="module-netrc.html">netrc</a></tt>:</b>
154 <dd>Parser for the <span class="file">.netrc</span> file format. The file
155 <span class="file">.netrc</span> is typically used by FTP clients to
156 load user authentication information before prompting
157 the user.
158 </dl>
159 <div class="seetext"><p>The file <span class="file">Tools/scripts/ftpmirror.py</span><a id='l2h-3340' xml:id='l2h-3340'></a>
160 in the Python source distribution is a script that can mirror
161 FTP sites, or portions thereof, using the <tt class="module">ftplib</tt> module.
162 It can be used as an extended example that applies this module.</p></div>
163</div>
164
165<P>
166
167<p><br /></p><hr class='online-navigation' />
168<div class='online-navigation'>
169<!--Table of Child-Links-->
170<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
171
172<UL CLASS="ChildLinks">
173<LI><A href="ftp-objects.html">11.7.1 FTP Objects</a>
174</ul>
175<!--End of Table of Child-Links-->
176</div>
177
178<DIV CLASS="navigation">
179<div class='online-navigation'>
180<p></p><hr />
181<table align="center" width="100%" cellpadding="0" cellspacing="2">
182<tr>
183<td class='online-navigation'><a rel="prev" title="11.6.3 Examples"
184 href="httplib-examples.html"><img src='../icons/previous.png'
185 border='0' height='32' alt='Previous Page' width='32' /></A></td>
186<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
187 href="internet.html"><img src='../icons/up.png'
188 border='0' height='32' alt='Up One Level' width='32' /></A></td>
189<td class='online-navigation'><a rel="next" title="11.7.1 FTP Objects"
190 href="ftp-objects.html"><img src='../icons/next.png'
191 border='0' height='32' alt='Next Page' width='32' /></A></td>
192<td align="center" width="100%">Python Library Reference</td>
193<td class='online-navigation'><a rel="contents" title="Table of Contents"
194 href="contents.html"><img src='../icons/contents.png'
195 border='0' height='32' alt='Contents' width='32' /></A></td>
196<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
197 border='0' height='32' alt='Module Index' width='32' /></a></td>
198<td class='online-navigation'><a rel="index" title="Index"
199 href="genindex.html"><img src='../icons/index.png'
200 border='0' height='32' alt='Index' width='32' /></A></td>
201</tr></table>
202<div class='online-navigation'>
203<b class="navlabel">Previous:</b>
204<a class="sectref" rel="prev" href="httplib-examples.html">11.6.3 Examples</A>
205<b class="navlabel">Up:</b>
206<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
207<b class="navlabel">Next:</b>
208<a class="sectref" rel="next" href="ftp-objects.html">11.7.1 FTP Objects</A>
209</div>
210</div>
211<hr />
212<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
213</DIV>
214<!--End of Navigation Panel-->
215<ADDRESS>
216See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
217</ADDRESS>
218</BODY>
219</HTML>