Sat, 31 Dec 2022 16:23:21 +0100
Updated copyright for 2023.
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
9653
e67609152c5e
Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
3 | # Copyright (c) 2012 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
7 | Module implementing an extension to the Python FTP class to support FTP |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
8 | proxies. |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
11 | import enum |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
12 | import ftplib # secok |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9324
diff
changeset
|
13 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | from socket import _GLOBAL_DEFAULT_TIMEOUT |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
17 | class EricFtpProxyError(ftplib.Error): |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | Class to signal an error related to proxy configuration. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | The error message starts with a three digit error code followed by a |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | space and the error string. Supported error codes are: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | <ul> |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
24 | <li>910: proxy error; the second number gives the category of the proxy |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
25 | error. The original response from the proxy is appended in the next |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
26 | line.</li> |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
27 | <li>930: proxy error; the second number gives the category of the proxy |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
28 | error. The original response from the proxy is appended in the next |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
29 | line.</li> |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
30 | <li>940: proxy error; the second number gives the category of the proxy |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
31 | error. The original response from the proxy is appended in the next |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
32 | line.</li> |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
33 | <li>950: proxy error; the second number gives the category of the proxy |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
34 | error. The original response from the proxy is appended in the next |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
35 | line.</li> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | <li>990: proxy usage is enabled but no proxy host given</li> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | <li>991: proxy usage is enabled but no proxy user given</li> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | <li>992: proxy usage is enabled but no proxy password given</li> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | </ul> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | pass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
45 | class EricFtpProxyType(enum.Enum): |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | Class defining the supported FTP proxy types. |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
50 | NO_PROXY = 0 # no proxy |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | NON_AUTHORIZING = 1 # non authorizing proxy |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | USER_SERVER = 2 # proxy login first, than user@remote.host |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | SITE = 3 # proxy login first, than use SITE command |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
54 | OPEN = 4 # proxy login first, than use OPEN command |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | USER_PROXYUSER_SERVER = 5 # one login for both |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
56 | PROXYUSER_SERVER = 6 |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
57 | # proxy login with remote host given, than normal remote login |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
58 | AUTH_RESP = 7 # authenticate to proxy with AUTH and RESP commands |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | BLUECOAT = 8 # bluecoat proxy |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
62 | class EricFtp(ftplib.FTP): |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | """ |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
64 | Class implementing an extension to the Python FTP class to support FTP |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
65 | proxies. |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
67 | |
9324
7f7f3e47b238
Set some security considerations to 'ok'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
68 | def __init__( # secok |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | self, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
70 | host="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
71 | user="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | password="", |
9324
7f7f3e47b238
Set some security considerations to 'ok'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
73 | acct="", |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
74 | proxyType=EricFtpProxyType.NO_PROXY, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | proxyHost="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
76 | proxyPort=ftplib.FTP_PORT, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
77 | proxyUser="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
78 | proxyPassword="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
79 | proxyAccount="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
80 | timeout=_GLOBAL_DEFAULT_TIMEOUT, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | ): |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
84 | |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
85 | @param host name of the FTP host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
86 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
87 | @param user user name for login to FTP host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
88 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
89 | @param password password for login to FTP host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
90 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
91 | @param acct account for login to FTP host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
92 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
93 | @param proxyType type of the FTP proxy |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
94 | @type EricFtpProxyType |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
95 | @param proxyHost name of the FTP proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
96 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
97 | @param proxyPort port of the FTP proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
98 | @type int |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
99 | @param proxyUser user name for login to the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
100 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
101 | @param proxyPassword password for login to the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
102 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
103 | @param proxyAccount accounting info for the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
104 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
105 | @param timeout timeout in seconds for blocking operations |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
106 | @type int |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8207
diff
changeset
|
108 | super().__init__() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
109 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | self.__timeout = timeout |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
111 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | self.__proxyType = proxyType |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | self.__proxyHost = proxyHost |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | self.__proxyPort = proxyPort |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | self.__proxyUser = proxyUser |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | self.__proxyPassword = proxyPassword |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | self.__proxyAccount = proxyAccount |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
118 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | self.__host = host |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | self.__port = ftplib.FTP_PORT |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | self.__user = user |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | self.__password = password |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | self.__acct = acct |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
124 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | if host: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | self.connect(host) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | if user: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | self.login(user, password, acct) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
129 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
130 | def setProxy( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
131 | self, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
132 | proxyType=EricFtpProxyType.NO_PROXY, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
133 | proxyHost="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
134 | proxyPort=ftplib.FTP_PORT, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
135 | proxyUser="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
136 | proxyPassword="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
137 | proxyAccount="", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
138 | ): |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | Public method to set the proxy configuration. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
141 | |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
142 | @param proxyType type of the FTP proxy |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
143 | @type EricFtpProxyType |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
144 | @param proxyHost name of the FTP proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
145 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
146 | @param proxyPort port of the FTP proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
147 | @type int |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
148 | @param proxyUser user name for login to the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
149 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
150 | @param proxyPassword password for login to the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
151 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
152 | @param proxyAccount accounting info for the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
153 | @type str |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | self.__proxyType = proxyType |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | self.__proxyHost = proxyHost |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | self.__proxyPort = proxyPort |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | self.__proxyUser = proxyUser |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | self.__proxyPassword = proxyPassword |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | self.__proxyAccount = proxyAccount |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
161 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
162 | def setProxyAuthentication(self, proxyUser="", proxyPassword="", proxyAccount=""): |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | Public method to set the proxy authentication info. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
165 | |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
166 | @param proxyUser user name for login to the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
167 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
168 | @param proxyPassword password for login to the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
169 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
170 | @param proxyAccount accounting info for the proxy |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
171 | @type str |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | self.__proxyUser = proxyUser |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | self.__proxyPassword = proxyPassword |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | self.__proxyAccount = proxyAccount |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
176 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | def connect(self, host="", port=0, timeout=-999): |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | Public method to connect to the given FTP server. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
180 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | This extended method connects to the proxy instead of the given host, |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | if a proxy is to be used. It throws an exception, if the proxy data |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | is incomplete. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
184 | |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
185 | @param host name of the FTP host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
186 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
187 | @param port port of the FTP host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
188 | @type int |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
189 | @param timeout timeout in seconds for blocking operations |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
190 | @type int |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
191 | @return welcome message of the server |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
192 | @rtype str |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
193 | @exception EricFtpProxyError raised to indicate a proxy related issue |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | if host: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | self.__host = host |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | if port: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | self.__port = port |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | if timeout != -999: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | self.__timeout = timeout |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
201 | |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
202 | if self.__proxyType != EricFtpProxyType.NO_PROXY: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | if not self.__proxyHost: |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
204 | raise EricFtpProxyError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
205 | "990 Proxy usage requested, but no proxy host given." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
206 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
207 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
208 | return super().connect(self.__proxyHost, self.__proxyPort, self.__timeout) |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
210 | return super().connect(self.__host, self.__port, self.__timeout) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
211 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
212 | def login(self, user="", password="", acct=""): # secok |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | Public method to login to the FTP server. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
215 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
216 | This extended method respects the FTP proxy configuration. There are |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
217 | many different FTP proxy products available. But unfortunately there |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
218 | is no standard for how o traverse a FTP proxy. The lis below shows |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
219 | the sequence of commands used. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
220 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | <table> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | <tr><td>user</td><td>Username for remote host</td></tr> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | <tr><td>pass</td><td>Password for remote host</td></tr> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | <tr><td>pruser</td><td>Username for FTP proxy</td></tr> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | <tr><td>prpass</td><td>Password for FTP proxy</td></tr> |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
226 | <tr><td>remote.host</td><td>Hostname of the remote FTP server</td> |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2872
diff
changeset
|
227 | </tr> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | </table> |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
229 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | <dl> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
231 | <dt>EricFtpProxyType.NO_PROXY:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | USER user<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | PASS pass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | </dd> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
236 | <dt>EricFtpProxyType.NON_AUTHORIZING:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | USER user@remote.host<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | PASS pass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | </dd> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
241 | <dt>EricFtpProxyType.USER_SERVER:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | USER pruser<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | PASS prpass<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | USER user@remote.host<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | PASS pass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | </dd> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
248 | <dt>EricFtpProxyType.SITE:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | USER pruser<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | PASS prpass<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | SITE remote.site<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | USER user<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | PASS pass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | </dd> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
256 | <dt>EricFtpProxyType.OPEN:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | USER pruser<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | PASS prpass<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | OPEN remote.site<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | USER user<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | PASS pass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | </dd> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
264 | <dt>EricFtpProxyType.USER_PROXYUSER_SERVER:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | USER user@pruser@remote.host<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | PASS pass@prpass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | </dd> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
269 | <dt>EricFtpProxyType.PROXYUSER_SERVER:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | USER pruser@remote.host<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | PASS prpass<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | USER user<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | PASS pass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
275 | </dd> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
276 | <dt>EricFtpProxyType.AUTH_RESP:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | USER user@remote.host<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | PASS pass<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | AUTH pruser<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
281 | RESP prpass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | </dd> |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
283 | <dt>EricFtpProxyType.BLUECOAT:</dt> |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | <dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
285 | USER user@remote.host pruser<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | PASS pass<br/> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | ACCT prpass |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | </dd> |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | </dl> |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
290 | |
8283
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
291 | @param user username for the remote host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
292 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
293 | @param password password for the remote host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
294 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
295 | @param acct accounting information for the remote host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
296 | @type str |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
297 | @return response sent by the remote host |
3139cbc98a14
Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8268
diff
changeset
|
298 | @rtype str |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
299 | @exception EricFtpProxyError raised to indicate a proxy related issue |
5726
e1dbd217214a
Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
300 | @exception ftplib.error_reply raised to indicate an FTP error reply |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | """ |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | if not user: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
303 | user = "anonymous" |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | if not password: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
305 | # make sure it is a string |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
306 | password = "" # secok |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | if not acct: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | # make sure it is a string |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | acct = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
310 | if user == "anonymous" and password in {"", "-"}: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | password += "anonymous@" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
312 | |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
313 | if self.__proxyType != EricFtpProxyType.NO_PROXY: |
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
314 | if self.__proxyType != EricFtpProxyType.NON_AUTHORIZING: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | # check, if a valid proxy configuration is known |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | if not self.__proxyUser: |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
317 | raise EricFtpProxyError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
318 | "991 Proxy usage requested, but no proxy user given" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
319 | ) |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | if not self.__proxyPassword: |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
321 | raise EricFtpProxyError( |
9576
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
322 | "992 Proxy usage requested, but no proxy password given" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
323 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
324 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
325 | if self.__proxyType in [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
326 | EricFtpProxyType.NON_AUTHORIZING, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
327 | EricFtpProxyType.AUTH_RESP, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
328 | EricFtpProxyType.BLUECOAT, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
329 | ]: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | user += "@" + self.__host |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
331 | if self.__proxyType == EricFtpProxyType.BLUECOAT: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | user += " " + self.__proxyUser |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | acct = self.__proxyPassword |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
334 | elif self.__proxyType == EricFtpProxyType.USER_PROXYUSER_SERVER: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
335 | user = "{0}@{1}@{2}".format(user, self.__proxyUser, self.__host) |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | password = "{0}@{1}".format(password, self.__proxyPassword) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | else: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | pruser = self.__proxyUser |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
339 | if self.__proxyType == EricFtpProxyType.USER_SERVER: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | user += "@" + self.__host |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
341 | elif self.__proxyType == EricFtpProxyType.PROXYUSER_SERVER: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | pruser += "@" + self.__host |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
343 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | # authenticate to the proxy first |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
345 | presp = self.sendcmd("USER " + pruser) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | if presp[0] == "3": |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
347 | presp = self.sendcmd("PASS " + self.__proxyPassword) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | if presp[0] == "3" and self.__proxyAccount: |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | presp = self.sendcmd("ACCT " + self.__proxyAccount) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | if presp[0] != "2": |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
351 | raise EricFtpProxyError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
352 | "9{0}0 Error authorizing at proxy\n{1}".format(presp[0], presp) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
353 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
354 | |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
355 | if self.__proxyType == EricFtpProxyType.SITE: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | # send SITE command |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | presp = self.sendcmd("SITE " + self.__host) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | if presp[0] != "2": |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
359 | raise EricFtpProxyError( |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | "9{0}0 Error sending SITE command\n{1}".format( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
361 | presp[0], presp |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
362 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
363 | ) |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
364 | elif self.__proxyType == EricFtpProxyType.OPEN: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | # send OPEN command |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
366 | presp = self.sendcmd("OPEN " + self.__host) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
367 | if presp[0] != "2": |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
368 | raise EricFtpProxyError( |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
369 | "9{0}0 Error sending OPEN command\n{1}".format( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
370 | presp[0], presp |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
371 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
372 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
373 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
374 | # authenticate to the remote host or combined to proxy and remote host |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
375 | resp = self.sendcmd("USER " + user) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | if resp[0] == "3": |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
377 | resp = self.sendcmd("PASS " + password) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | if resp[0] == "3": |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | resp = self.sendcmd("ACCT " + acct) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | if resp[0] != "2": |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
381 | raise ftplib.error_reply(resp) # secok |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
382 | |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
383 | if self.__proxyType == EricFtpProxyType.AUTH_RESP: |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | # authorize to the FTP proxy |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | presp = self.sendcmd("AUTH " + self.__proxyUser) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | if presp[0] == "3": |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
387 | presp = self.sendcmd("RESP " + self.__proxyPassword) |
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | if presp[0] != "2": |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
389 | raise EricFtpProxyError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
390 | "9{0}0 Error authorizing at proxy\n{1}".format(presp[0], presp) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
391 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
392 | |
2074
5cb87968aad5
Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | return resp |