eric6/E5Network/E5Ftp.py

Wed, 30 Dec 2020 11:00:05 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:05 +0100
changeset 7923
91e843545d9a
parent 7780
41420f82c0ac
child 8207
d359172d11be
permissions
-rw-r--r--

Updated copyright for 2021.

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
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
11 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
12 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
13
5cb87968aad5 Reworked the FTP stuff to 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 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
16 """
5cb87968aad5 Reworked the FTP stuff to 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 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
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 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
20 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
21 <ul>
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
22 <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
23 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
24 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
25 <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
26 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
27 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
28 <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
29 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
30 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
31 <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
32 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
33 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
34 <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
35 <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
36 <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
37 </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
38 """
5cb87968aad5 Reworked the FTP stuff to 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 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
40
5cb87968aad5 Reworked the FTP stuff to 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 class E5FtpProxyType(object):
5cb87968aad5 Reworked the FTP stuff to 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 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
45 """
5cb87968aad5 Reworked the FTP stuff to 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 NoProxy = 0 # no 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
47 NonAuthorizing = 1 # non authorizing 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
48 UserAtServer = 2 # proxy login first, than user@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
49 Site = 3 # proxy login first, than use 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
50 Open = 4 # proxy login first, than use 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
51 UserAtProxyuserAtServer = 5 # one login for both
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
52 ProxyuserAtServer = 6
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
53 # proxy login with remote host given, than normal remote login
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 AuthResp = 7 # authenticate to proxy with AUTH and RESP commands
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
55 Bluecoat = 8 # bluecoat 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
56
5cb87968aad5 Reworked the FTP stuff to 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 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
59 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
60 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
61 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
62 """
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
63 def __init__(self, host="", user="", password="", acct="", # secok
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
64 proxyType=E5FtpProxyType.NoProxy, proxyHost="",
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
65 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
66 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
67 """
5cb87968aad5 Reworked the FTP stuff to 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 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
69
5cb87968aad5 Reworked the FTP stuff to 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 @param host name of the FTP host (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
71 @param user user name for login to FTP host (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
72 @param password password for login to FTP host (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
73 @param acct account for login to FTP host (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
74 @param proxyType type of the FTP proxy (integer 0 to 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
75 @param proxyHost name of the FTP proxy (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
76 @param proxyPort port of the FTP proxy (integer)
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 @param proxyUser user name for login to the proxy (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
78 @param proxyPassword password for login to the proxy (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
79 @param proxyAccount accounting info for the proxy (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
80 @param timeout timeout in seconds for blocking operations (integer)
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
2911
ce77f0b1ee67 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525 2872
diff changeset
82 super(E5Ftp, self).__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
83
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
84 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
85
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 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
87 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
88 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
89 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
90 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
91 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
92
5cb87968aad5 Reworked the FTP stuff to 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 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
94 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
95 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
96 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
97 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
98
5cb87968aad5 Reworked the FTP stuff to 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 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
100 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
101 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
102 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
103
5cb87968aad5 Reworked the FTP stuff to 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 def setProxy(self, proxyType=E5FtpProxyType.NoProxy, proxyHost="",
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
105 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
106 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
107 """
5cb87968aad5 Reworked the FTP stuff to 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 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
109
5cb87968aad5 Reworked the FTP stuff to 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 @param proxyType type of the FTP proxy (integer 0 to 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
111 @param proxyHost name of the FTP proxy (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
112 @param proxyPort port of the FTP proxy (integer)
5cb87968aad5 Reworked the FTP stuff to 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 @param proxyUser user name for login to the proxy (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
114 @param proxyPassword password for login to the proxy (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
115 @param proxyAccount accounting info for the proxy (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
116 """
5cb87968aad5 Reworked the FTP stuff to 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.__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
118 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
119 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
120 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
121 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
122 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
123
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
124 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
125 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
126 """
5cb87968aad5 Reworked the FTP stuff to 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 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
128
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 @param proxyUser user name for login to the proxy (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
130 @param proxyPassword password for login to the proxy (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
131 @param proxyAccount accounting info for the proxy (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
132 """
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 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
134 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
135 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
136
5cb87968aad5 Reworked the FTP stuff to 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 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
138 """
5cb87968aad5 Reworked the FTP stuff to 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 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
140
5cb87968aad5 Reworked the FTP stuff to 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 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
142 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
143 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
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 @param host name of the FTP host (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
146 @param port port of the FTP host (integer)
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 @param timeout timeout in seconds for blocking operations (integer)
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 @return welcome message of the server (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
149 @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
150 """
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 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
152 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
153 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
154 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
155 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
156 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
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 if self.__proxyType != E5FtpProxyType.NoProxy:
5cb87968aad5 Reworked the FTP stuff to 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 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
160 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
161 "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
162
3057
10516539f238 Merge with default branch after shorten the code lines to max. 79 characters.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2911 2990
diff changeset
163 return super(E5Ftp, self).connect(
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
164 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
165 else:
3065
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
166 return super(E5Ftp, self).connect(
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
167 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
168
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
169 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
170 """
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 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
172
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
173 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
174 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
175 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
176 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
177
5cb87968aad5 Reworked the FTP stuff to 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 <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
179 <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
180 <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
181 <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
182 <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
183 <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
184 </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
185 </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
186
5cb87968aad5 Reworked the FTP stuff to 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 <dl>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
188 <dt>E5FtpProxyType.NoProxy:</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
189 <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
190 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
191 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
192 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
193 <dt>E5FtpProxyType.NonAuthorizing:</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
194 <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
195 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
196 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
197 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
198 <dt>E5FtpProxyType.UserAtServer:</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
199 <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
200 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
201 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
202 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
203 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
204 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
205 <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
206 <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
207 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
208 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
209 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
210 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
211 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
212 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
213 <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
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 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
216 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
217 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
218 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
219 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
220 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
221 <dt>E5FtpProxyType.UserAtProxyuserAtServer:</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
222 <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
223 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
224 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
225 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
226 <dt>E5FtpProxyType.ProxyuserAtServer:</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
227 <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
228 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
229 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
230 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
231 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
232 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
233 <dt>E5FtpProxyType.AuthResp:</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
234 <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
235 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
236 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
237 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
238 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
239 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
240 <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
241 <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
242 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
243 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
244 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
245 </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
246 </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
247
5cb87968aad5 Reworked the FTP stuff to 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 @param user username for the remote host (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
249 @param password password for the remote host (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
250 @param acct accounting information for the remote host (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
251 @return response sent by the remote host (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
252 @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
253 @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
254 """
5cb87968aad5 Reworked the FTP stuff to 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 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
256 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
257 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
258 # 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
259 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
260 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
261 # 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
262 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
263 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
264 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
265
5cb87968aad5 Reworked the FTP stuff to 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 if self.__proxyType != E5FtpProxyType.NoProxy:
5cb87968aad5 Reworked the FTP stuff to 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 if self.__proxyType != E5FtpProxyType.NonAuthorizing:
5cb87968aad5 Reworked the FTP stuff to 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 # 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
269 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
270 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
271 "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
272 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
273 raise E5FtpProxyError(
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
274 "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
275 " 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
276
5cb87968aad5 Reworked the FTP stuff to 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 if self.__proxyType in [E5FtpProxyType.NonAuthorizing,
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2990
diff changeset
278 E5FtpProxyType.AuthResp,
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2990
diff changeset
279 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
280 user += "@" + 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
281 if self.__proxyType == E5FtpProxyType.Bluecoat:
5cb87968aad5 Reworked the FTP stuff to 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 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
283 acct = 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
284 elif self.__proxyType == E5FtpProxyType.UserAtProxyuserAtServer:
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
285 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
286 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
287 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
288 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
289 pruser = 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
290 if self.__proxyType == E5FtpProxyType.UserAtServer:
5cb87968aad5 Reworked the FTP stuff to 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 user += "@" + 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
292 elif self.__proxyType == E5FtpProxyType.ProxyuserAtServer:
5cb87968aad5 Reworked the FTP stuff to 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 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
294
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 # 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
296 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
297 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
298 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
299 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
300 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
301 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
302 raise E5FtpProxyError(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
303 "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
304 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
305
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 if self.__proxyType == E5FtpProxyType.Site:
5cb87968aad5 Reworked the FTP stuff to 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 # 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
308 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
309 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
310 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
311 "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
312 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
313 elif self.__proxyType == E5FtpProxyType.Open:
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 # 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
315 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
316 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
317 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
318 "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
319 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
320
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 # 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
322 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
323 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
324 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
325 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
326 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
327 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
328 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
329
5cb87968aad5 Reworked the FTP stuff to 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 self.__proxyType == E5FtpProxyType.AuthResp:
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 # 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
332 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
333 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
334 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
335 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
336 raise E5FtpProxyError(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
337 "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
338 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
339
5cb87968aad5 Reworked the FTP stuff to 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 return resp

eric ide

mercurial