|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.E5Network.E5Ftp</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.E5Network.E5Ftp</h1> |
|
23 <p> |
|
24 Module implementing an extension to the Python FTP class to support FTP |
|
25 proxies. |
|
26 </p> |
|
27 <h3>Global Attributes</h3> |
|
28 <table> |
|
29 <tr><td>None</td></tr> |
|
30 </table> |
|
31 <h3>Classes</h3> |
|
32 <table> |
|
33 <tr> |
|
34 <td><a href="#E5Ftp">E5Ftp</a></td> |
|
35 <td>Class implementing an extension to the Python FTP class to support FTP proxies.</td> |
|
36 </tr><tr> |
|
37 <td><a href="#E5FtpProxyError">E5FtpProxyError</a></td> |
|
38 <td>Class to signal an error related to proxy configuration.</td> |
|
39 </tr><tr> |
|
40 <td><a href="#E5FtpProxyType">E5FtpProxyType</a></td> |
|
41 <td>Class defining the supported FTP proxy types.</td> |
|
42 </tr> |
|
43 </table> |
|
44 <h3>Functions</h3> |
|
45 <table> |
|
46 <tr><td>None</td></tr> |
|
47 </table> |
|
48 <hr /><hr /> |
|
49 <a NAME="E5Ftp" ID="E5Ftp"></a> |
|
50 <h2>E5Ftp</h2> |
|
51 <p> |
|
52 Class implementing an extension to the Python FTP class to support FTP |
|
53 proxies. |
|
54 </p> |
|
55 <h3>Derived from</h3> |
|
56 ftplib.FTP |
|
57 <h3>Class Attributes</h3> |
|
58 <table> |
|
59 <tr><td>None</td></tr> |
|
60 </table> |
|
61 <h3>Class Methods</h3> |
|
62 <table> |
|
63 <tr><td>None</td></tr> |
|
64 </table> |
|
65 <h3>Methods</h3> |
|
66 <table> |
|
67 <tr> |
|
68 <td><a href="#E5Ftp.__init__">E5Ftp</a></td> |
|
69 <td>Constructor</td> |
|
70 </tr><tr> |
|
71 <td><a href="#E5Ftp.connect">connect</a></td> |
|
72 <td>Public method to connect to the given FTP server.</td> |
|
73 </tr><tr> |
|
74 <td><a href="#E5Ftp.login">login</a></td> |
|
75 <td>Public method to login to the FTP server.</td> |
|
76 </tr><tr> |
|
77 <td><a href="#E5Ftp.setProxy">setProxy</a></td> |
|
78 <td>Public method to set the proxy configuration.</td> |
|
79 </tr><tr> |
|
80 <td><a href="#E5Ftp.setProxyAuthentication">setProxyAuthentication</a></td> |
|
81 <td>Public method to set the proxy authentication info.</td> |
|
82 </tr> |
|
83 </table> |
|
84 <h3>Static Methods</h3> |
|
85 <table> |
|
86 <tr><td>None</td></tr> |
|
87 </table> |
|
88 <a NAME="E5Ftp.__init__" ID="E5Ftp.__init__"></a> |
|
89 <h4>E5Ftp (Constructor)</h4> |
|
90 <b>E5Ftp</b>(<i>host="", user="", password="", acct="", proxyType=E5FtpProxyType.NoProxy, proxyHost="", proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="", proxyAccount="", timeout=_GLOBAL_DEFAULT_TIMEOUT</i>) |
|
91 <p> |
|
92 Constructor |
|
93 </p><dl> |
|
94 <dt><i>host</i></dt> |
|
95 <dd> |
|
96 name of the FTP host (string) |
|
97 </dd><dt><i>user</i></dt> |
|
98 <dd> |
|
99 user name for login to FTP host (string) |
|
100 </dd><dt><i>password</i></dt> |
|
101 <dd> |
|
102 password for login to FTP host (string) |
|
103 </dd><dt><i>acct</i></dt> |
|
104 <dd> |
|
105 account for login to FTP host (string) |
|
106 </dd><dt><i>proxyType</i></dt> |
|
107 <dd> |
|
108 type of the FTP proxy (integer 0 to 8) |
|
109 </dd><dt><i>proxyHost</i></dt> |
|
110 <dd> |
|
111 name of the FTP proxy (string) |
|
112 </dd><dt><i>proxyPort</i></dt> |
|
113 <dd> |
|
114 port of the FTP proxy (integer) |
|
115 </dd><dt><i>proxyUser</i></dt> |
|
116 <dd> |
|
117 user name for login to the proxy (string) |
|
118 </dd><dt><i>proxyPassword</i></dt> |
|
119 <dd> |
|
120 password for login to the proxy (string) |
|
121 </dd><dt><i>proxyAccount</i></dt> |
|
122 <dd> |
|
123 accounting info for the proxy (string) |
|
124 </dd><dt><i>timeout</i></dt> |
|
125 <dd> |
|
126 timeout in seconds for blocking operations (integer) |
|
127 </dd> |
|
128 </dl><a NAME="E5Ftp.connect" ID="E5Ftp.connect"></a> |
|
129 <h4>E5Ftp.connect</h4> |
|
130 <b>connect</b>(<i>host="", port=0, timeout=-999</i>) |
|
131 <p> |
|
132 Public method to connect to the given FTP server. |
|
133 </p><p> |
|
134 This extended method connects to the proxy instead of the given host, |
|
135 if a proxy is to be used. It throws an exception, if the proxy data |
|
136 is incomplete. |
|
137 </p><dl> |
|
138 <dt><i>host</i></dt> |
|
139 <dd> |
|
140 name of the FTP host (string) |
|
141 </dd><dt><i>port</i></dt> |
|
142 <dd> |
|
143 port of the FTP host (integer) |
|
144 </dd><dt><i>timeout</i></dt> |
|
145 <dd> |
|
146 timeout in seconds for blocking operations (integer) |
|
147 </dd> |
|
148 </dl><dl> |
|
149 <dt>Returns:</dt> |
|
150 <dd> |
|
151 welcome message of the server (string) |
|
152 </dd> |
|
153 </dl><dl> |
|
154 <dt>Raises <b>E5FtpProxyError</b>:</dt> |
|
155 <dd> |
|
156 raised to indicate a proxy related issue |
|
157 </dd> |
|
158 </dl><a NAME="E5Ftp.login" ID="E5Ftp.login"></a> |
|
159 <h4>E5Ftp.login</h4> |
|
160 <b>login</b>(<i>user="", password="", acct=""</i>) |
|
161 <p> |
|
162 Public method to login to the FTP server. |
|
163 </p><p> |
|
164 This extended method respects the FTP proxy configuration. There are |
|
165 many different FTP proxy products available. But unfortunately there |
|
166 is no standard for how o traverse a FTP proxy. The lis below shows |
|
167 the sequence of commands used. |
|
168 </p><p> |
|
169 <table> |
|
170 <tr><td>user</td><td>Username for remote host</td></tr> |
|
171 <tr><td>pass</td><td>Password for remote host</td></tr> |
|
172 <tr><td>pruser</td><td>Username for FTP proxy</td></tr> |
|
173 <tr><td>prpass</td><td>Password for FTP proxy</td></tr> |
|
174 <tr><td>remote.host</td><td>Hostname of the remote FTP server</td> |
|
175 </tr> |
|
176 </table> |
|
177 </p><p> |
|
178 <dl> |
|
179 <dt>E5FtpProxyType.NoProxy:</dt> |
|
180 <dd> |
|
181 USER user<br/> |
|
182 PASS pass |
|
183 </dd> |
|
184 <dt>E5FtpProxyType.NonAuthorizing:</dt> |
|
185 <dd> |
|
186 USER user@remote.host<br/> |
|
187 PASS pass |
|
188 </dd> |
|
189 <dt>E5FtpProxyType.UserAtServer:</dt> |
|
190 <dd> |
|
191 USER pruser<br/> |
|
192 PASS prpass<br/> |
|
193 USER user@remote.host<br/> |
|
194 PASS pass |
|
195 </dd> |
|
196 <dt>E5FtpProxyType.Site:</dt> |
|
197 <dd> |
|
198 USER pruser<br/> |
|
199 PASS prpass<br/> |
|
200 SITE remote.site<br/> |
|
201 USER user<br/> |
|
202 PASS pass |
|
203 </dd> |
|
204 <dt>E5FtpProxyType.Open:</dt> |
|
205 <dd> |
|
206 USER pruser<br/> |
|
207 PASS prpass<br/> |
|
208 OPEN remote.site<br/> |
|
209 USER user<br/> |
|
210 PASS pass |
|
211 </dd> |
|
212 <dt>E5FtpProxyType.UserAtProxyuserAtServer:</dt> |
|
213 <dd> |
|
214 USER user@pruser@remote.host<br/> |
|
215 PASS pass@prpass |
|
216 </dd> |
|
217 <dt>E5FtpProxyType.ProxyuserAtServer:</dt> |
|
218 <dd> |
|
219 USER pruser@remote.host<br/> |
|
220 PASS prpass<br/> |
|
221 USER user<br/> |
|
222 PASS pass |
|
223 </dd> |
|
224 <dt>E5FtpProxyType.AuthResp:</dt> |
|
225 <dd> |
|
226 USER user@remote.host<br/> |
|
227 PASS pass<br/> |
|
228 AUTH pruser<br/> |
|
229 RESP prpass |
|
230 </dd> |
|
231 <dt>E5FtpProxyType.Bluecoat:</dt> |
|
232 <dd> |
|
233 USER user@remote.host pruser<br/> |
|
234 PASS pass<br/> |
|
235 ACCT prpass |
|
236 </dd> |
|
237 </dl> |
|
238 </p><dl> |
|
239 <dt><i>user</i></dt> |
|
240 <dd> |
|
241 username for the remote host (string) |
|
242 </dd><dt><i>password</i></dt> |
|
243 <dd> |
|
244 password for the remote host (string) |
|
245 </dd><dt><i>acct</i></dt> |
|
246 <dd> |
|
247 accounting information for the remote host (string) |
|
248 </dd> |
|
249 </dl><dl> |
|
250 <dt>Returns:</dt> |
|
251 <dd> |
|
252 response sent by the remote host (string) |
|
253 </dd> |
|
254 </dl><dl> |
|
255 <dt>Raises <b>E5FtpProxyError</b>:</dt> |
|
256 <dd> |
|
257 raised to indicate a proxy related issue |
|
258 </dd><dt>Raises <b>ftplib.error_reply</b>:</dt> |
|
259 <dd> |
|
260 raised to indicate an FTP error reply |
|
261 </dd> |
|
262 </dl><a NAME="E5Ftp.setProxy" ID="E5Ftp.setProxy"></a> |
|
263 <h4>E5Ftp.setProxy</h4> |
|
264 <b>setProxy</b>(<i>proxyType=E5FtpProxyType.NoProxy, proxyHost="", proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="", proxyAccount=""</i>) |
|
265 <p> |
|
266 Public method to set the proxy configuration. |
|
267 </p><dl> |
|
268 <dt><i>proxyType</i></dt> |
|
269 <dd> |
|
270 type of the FTP proxy (integer 0 to 8) |
|
271 </dd><dt><i>proxyHost</i></dt> |
|
272 <dd> |
|
273 name of the FTP proxy (string) |
|
274 </dd><dt><i>proxyPort</i></dt> |
|
275 <dd> |
|
276 port of the FTP proxy (integer) |
|
277 </dd><dt><i>proxyUser</i></dt> |
|
278 <dd> |
|
279 user name for login to the proxy (string) |
|
280 </dd><dt><i>proxyPassword</i></dt> |
|
281 <dd> |
|
282 password for login to the proxy (string) |
|
283 </dd><dt><i>proxyAccount</i></dt> |
|
284 <dd> |
|
285 accounting info for the proxy (string) |
|
286 </dd> |
|
287 </dl><a NAME="E5Ftp.setProxyAuthentication" ID="E5Ftp.setProxyAuthentication"></a> |
|
288 <h4>E5Ftp.setProxyAuthentication</h4> |
|
289 <b>setProxyAuthentication</b>(<i>proxyUser="", proxyPassword="", proxyAccount=""</i>) |
|
290 <p> |
|
291 Public method to set the proxy authentication info. |
|
292 </p><dl> |
|
293 <dt><i>proxyUser</i></dt> |
|
294 <dd> |
|
295 user name for login to the proxy (string) |
|
296 </dd><dt><i>proxyPassword</i></dt> |
|
297 <dd> |
|
298 password for login to the proxy (string) |
|
299 </dd><dt><i>proxyAccount</i></dt> |
|
300 <dd> |
|
301 accounting info for the proxy (string) |
|
302 </dd> |
|
303 </dl> |
|
304 <div align="right"><a href="#top">Up</a></div> |
|
305 <hr /><hr /> |
|
306 <a NAME="E5FtpProxyError" ID="E5FtpProxyError"></a> |
|
307 <h2>E5FtpProxyError</h2> |
|
308 <p> |
|
309 Class to signal an error related to proxy configuration. |
|
310 </p><p> |
|
311 The error message starts with a three digit error code followed by a |
|
312 space and the error string. Supported error codes are: |
|
313 <ul> |
|
314 <li>910: proxy error; the second number gives the category of the proxy |
|
315 error. The original response from the proxy is appended in the next |
|
316 line.</li> |
|
317 <li>930: proxy error; the second number gives the category of the proxy |
|
318 error. The original response from the proxy is appended in the next |
|
319 line.</li> |
|
320 <li>940: proxy error; the second number gives the category of the proxy |
|
321 error. The original response from the proxy is appended in the next |
|
322 line.</li> |
|
323 <li>950: proxy error; the second number gives the category of the proxy |
|
324 error. The original response from the proxy is appended in the next |
|
325 line.</li> |
|
326 <li>990: proxy usage is enabled but no proxy host given</li> |
|
327 <li>991: proxy usage is enabled but no proxy user given</li> |
|
328 <li>992: proxy usage is enabled but no proxy password given</li> |
|
329 </ul> |
|
330 </p> |
|
331 <h3>Derived from</h3> |
|
332 ftplib.Error |
|
333 <h3>Class Attributes</h3> |
|
334 <table> |
|
335 <tr><td>None</td></tr> |
|
336 </table> |
|
337 <h3>Class Methods</h3> |
|
338 <table> |
|
339 <tr><td>None</td></tr> |
|
340 </table> |
|
341 <h3>Methods</h3> |
|
342 <table> |
|
343 <tr><td>None</td></tr> |
|
344 </table> |
|
345 <h3>Static Methods</h3> |
|
346 <table> |
|
347 <tr><td>None</td></tr> |
|
348 </table> |
|
349 |
|
350 <div align="right"><a href="#top">Up</a></div> |
|
351 <hr /><hr /> |
|
352 <a NAME="E5FtpProxyType" ID="E5FtpProxyType"></a> |
|
353 <h2>E5FtpProxyType</h2> |
|
354 <p> |
|
355 Class defining the supported FTP proxy types. |
|
356 </p> |
|
357 <h3>Derived from</h3> |
|
358 object |
|
359 <h3>Class Attributes</h3> |
|
360 <table> |
|
361 <tr><td>AuthResp</td></tr><tr><td>Bluecoat</td></tr><tr><td>NoProxy</td></tr><tr><td>NonAuthorizing</td></tr><tr><td>Open</td></tr><tr><td>ProxyuserAtServer</td></tr><tr><td>Site</td></tr><tr><td>UserAtProxyuserAtServer</td></tr><tr><td>UserAtServer</td></tr> |
|
362 </table> |
|
363 <h3>Class Methods</h3> |
|
364 <table> |
|
365 <tr><td>None</td></tr> |
|
366 </table> |
|
367 <h3>Methods</h3> |
|
368 <table> |
|
369 <tr><td>None</td></tr> |
|
370 </table> |
|
371 <h3>Static Methods</h3> |
|
372 <table> |
|
373 <tr><td>None</td></tr> |
|
374 </table> |
|
375 |
|
376 <div align="right"><a href="#top">Up</a></div> |
|
377 <hr /> |
|
378 </body></html> |