eric6/E5Network/E5Ftp.py

Sun, 02 May 2021 18:13:23 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 May 2021 18:13:23 +0200
changeset 8283
3139cbc98a14
parent 8268
6b8128e0c9d1
permissions
-rw-r--r--

Modernized some more code E5Ftp).

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2012 - 2021 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
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
12 import ftplib # 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
13 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
14
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 class E5FtpProxyError(ftplib.Error):
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
17 """
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 Class to signal an error related to proxy configuration.
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
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
20 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
21 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
22 <ul>
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
23 <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
24 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
25 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
26 <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
27 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
28 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
29 <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
30 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
31 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
32 <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
33 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
34 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
35 <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
36 <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
37 <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
38 </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
39 """
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 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
41
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
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
43 class E5FtpProxyType(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
44 """
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
45 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
46 """
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
47 NO_PROXY = 0 # no proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
48 NON_AUTHORIZING = 1 # non authorizing proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
49 USER_SERVER = 2 # proxy login first, than user@remote.host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
50 SITE = 3 # proxy login first, than use SITE command
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
51 OPEN = 4 # proxy login first, than use OPEN command
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
52 USER_PROXYUSER_SERVER = 5 # one login for both
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
53 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
54 # 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
55 AUTH_RESP = 7 # authenticate to proxy with AUTH and RESP commands
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
56 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
57
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
58
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
59 class E5Ftp(ftplib.FTP):
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 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
61 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
62 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
63 """
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
64 def __init__(self, host="", user="", password="", acct="", # secok
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
65 proxyType=E5FtpProxyType.NO_PROXY, proxyHost="",
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
66 proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="",
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
67 proxyAccount="", timeout=_GLOBAL_DEFAULT_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
68 """
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
69 Constructor
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
70
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
71 @param host name of the FTP host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
72 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
73 @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
74 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
75 @param password password for login to FTP host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
76 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
77 @param acct account for login to FTP host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
78 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
79 @param proxyType type of the FTP proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
80 @type E5FtpProxyType
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
81 @param proxyHost name of the FTP proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
82 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
83 @param proxyPort port of the FTP proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
84 @type int
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
85 @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
86 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
87 @param proxyPassword password for login to the proxy
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 proxyAccount accounting info for the proxy
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 timeout timeout in seconds for blocking operations
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
92 @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
93 """
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
94 super().__init__()
2872
13f12f81cb7b Fixed the forgotten call to the parent class constructur in the E5Ftp class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
95
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
96 self.__timeout = 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
97
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
98 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
99 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
100 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
101 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
102 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
103 self.__proxyAccount = 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
104
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
105 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
106 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
107 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
108 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
109 self.__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
110
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
111 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
112 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
113 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
114 self.login(user, password, 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
115
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
116 def setProxy(self, proxyType=E5FtpProxyType.NO_PROXY, proxyHost="",
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
117 proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="",
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
118 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
119 """
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 Public method to set the proxy configuration.
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
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
122 @param proxyType type of the FTP proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
123 @type E5FtpProxyType
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
124 @param proxyHost name of the FTP proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
125 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
126 @param proxyPort port of the FTP proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
127 @type int
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
128 @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
129 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
130 @param proxyPassword password for login to the proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
131 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
132 @param proxyAccount accounting info for the proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
133 @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
134 """
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
135 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
136 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
137 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
138 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
139 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
140 self.__proxyAccount = 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
141
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
142 def setProxyAuthentication(self, proxyUser="", proxyPassword="",
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
143 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
144 """
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
145 Public method to set the proxy authentication info.
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
146
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
147 @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
148 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
149 @param proxyPassword password for login to the proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
150 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
151 @param proxyAccount accounting info for the proxy
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
152 @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
153 """
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 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
155 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
156 self.__proxyAccount = 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
157
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 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
159 """
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 Public method to connect to the given FTP server.
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
161
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
162 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
163 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
164 is incomplete.
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
165
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
166 @param host name of the FTP host
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 port port of the FTP host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
169 @type int
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
170 @param timeout timeout in seconds for blocking operations
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
171 @type int
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
172 @return welcome message of the server
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
173 @rtype 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
174 @exception E5FtpProxyError raised to indicate a proxy related issue
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 """
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
176 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
177 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
178 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
179 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
180 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
181 self.__timeout = 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
182
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
183 if self.__proxyType != E5FtpProxyType.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
184 if not self.__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
185 raise E5FtpProxyError(
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
186 "990 Proxy usage requested, but no proxy host given.")
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
187
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
188 return super().connect(
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
189 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
190 else:
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
191 return super().connect(
3065
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
192 self.__host, self.__port, 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
193
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
194 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
195 """
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 Public method to login to the FTP server.
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
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
198 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
199 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
200 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
201 the sequence of commands used.
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
202
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 <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
204 <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
205 <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
206 <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
207 <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
208 <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
209 </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
210 </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
211
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
212 <dl>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
213 <dt>E5FtpProxyType.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
214 <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
215 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
216 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
217 </dd>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
218 <dt>E5FtpProxyType.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
219 <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
220 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
221 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
222 </dd>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
223 <dt>E5FtpProxyType.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
224 <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
225 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
226 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
227 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
228 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
229 </dd>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
230 <dt>E5FtpProxyType.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
231 <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
232 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
233 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
234 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
235 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
236 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
237 </dd>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
238 <dt>E5FtpProxyType.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
239 <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
240 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
241 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
242 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
243 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
244 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
245 </dd>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
246 <dt>E5FtpProxyType.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
247 <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
248 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
249 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
250 </dd>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
251 <dt>E5FtpProxyType.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
252 <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
253 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
254 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
255 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
256 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
257 </dd>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
258 <dt>E5FtpProxyType.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
259 <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
260 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
261 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
262 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
263 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
264 </dd>
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
265 <dt>E5FtpProxyType.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
266 <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
267 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
268 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
269 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
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 </dl>
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
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
273 @param user username for the remote host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
274 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
275 @param password password for the remote host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
276 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
277 @param acct accounting information for the remote host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
278 @type str
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
279 @return response sent by the remote host
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
280 @rtype 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
281 @exception E5FtpProxyError 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
282 @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
283 """
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 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
285 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
286 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
287 # make sure it is a string
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
288 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
289 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
290 # 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
291 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
292 if user == "anonymous" and password in {'', '-'}:
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
293 password += "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
294
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
295 if self.__proxyType != E5FtpProxyType.NO_PROXY:
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
296 if self.__proxyType != E5FtpProxyType.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
297 # 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
298 if not 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
299 raise E5FtpProxyError(
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
300 "991 Proxy usage requested, but no proxy user given")
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 if not 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
302 raise E5FtpProxyError(
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
303 "992 Proxy usage requested, but no proxy password"
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
304 " given")
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
305
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
306 if self.__proxyType in [E5FtpProxyType.NON_AUTHORIZING,
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
307 E5FtpProxyType.AUTH_RESP,
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
308 E5FtpProxyType.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
309 user += "@" + self.__host
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
310 if self.__proxyType == E5FtpProxyType.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
311 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
312 acct = self.__proxyPassword
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
313 elif self.__proxyType == E5FtpProxyType.USER_PROXYUSER_SERVER:
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
314 user = "{0}@{1}@{2}".format(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
315 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
316 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
317 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
318 pruser = self.__proxyUser
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
319 if self.__proxyType == E5FtpProxyType.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
320 user += "@" + self.__host
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
321 elif self.__proxyType == E5FtpProxyType.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
322 pruser += "@" + 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
323
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
324 # 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
325 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
326 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
327 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
328 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
329 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
330 if presp[0] != "2":
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
331 raise E5FtpProxyError(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
332 "9{0}0 Error authorizing at proxy\n{1}".format(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
333 presp[0], presp))
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
334
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
335 if self.__proxyType == E5FtpProxyType.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
336 # 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
337 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
338 if presp[0] != "2":
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
339 raise E5FtpProxyError(
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 "9{0}0 Error sending SITE command\n{1}".format(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
341 presp[0], presp))
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
342 elif self.__proxyType == E5FtpProxyType.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
343 # 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
344 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
345 if presp[0] != "2":
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 raise E5FtpProxyError(
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 "9{0}0 Error sending OPEN command\n{1}".format(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
348 presp[0], presp))
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
349
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 # 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
351 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
352 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
353 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
354 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
355 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
356 if resp[0] != "2":
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
357 raise ftplib.error_reply(resp) # 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
358
8283
3139cbc98a14 Modernized some more code E5Ftp).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8268
diff changeset
359 if self.__proxyType == E5FtpProxyType.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
360 # 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
361 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
362 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
363 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
364 if presp[0] != "2":
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
365 raise E5FtpProxyError(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
366 "9{0}0 Error authorizing at proxy\n{1}".format(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
367 presp[0], presp))
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
368
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 return resp

eric ide

mercurial