E5Network/E5Ftp.py

Mon, 02 Apr 2018 12:04:18 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 02 Apr 2018 12:04:18 +0200
branch
maintenance
changeset 6206
a02b03b7bfec
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
permissions
-rw-r--r--

Merged with default branch to prepare new release.

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
6048
82ad8ec9548c Updated copyright for 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5726
diff changeset
3 # Copyright (c) 2012 - 2018 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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3065
diff changeset
11 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
12
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 import ftplib
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from socket import _GLOBAL_DEFAULT_TIMEOUT
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
5cb87968aad5 Reworked the FTP stuff to 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 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
18 """
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Class to signal an error related to proxy configuration.
5cb87968aad5 Reworked the FTP stuff to 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
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 The error message starts with a three digit error code followed by a
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 space and the error string. Supported error codes are:
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 <ul>
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
24 <li>910: proxy error; the second number gives the category of the proxy
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
25 error. The original response from the proxy is appended in the next
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
26 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
27 <li>930: proxy error; the second number gives the category of the proxy
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
28 error. The original response from the proxy is appended in the next
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
29 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
30 <li>940: proxy error; the second number gives the category of the proxy
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
31 error. The original response from the proxy is appended in the next
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
32 line.</li>
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
33 <li>950: proxy error; the second number gives the category of the proxy
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
34 error. The original response from the proxy is appended in the next
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
35 line.</li>
2074
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 <li>990: proxy usage is enabled but no proxy host given</li>
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 <li>991: proxy usage is enabled but no proxy user given</li>
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 <li>992: proxy usage is enabled but no proxy password given</li>
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 </ul>
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
5cb87968aad5 Reworked the FTP stuff to 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 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
42
5cb87968aad5 Reworked the FTP stuff to 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 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
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 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
47 """
5cb87968aad5 Reworked the FTP stuff to 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 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
49 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
50 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
51 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
52 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
53 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
54 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
55 # 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
56 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
57 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
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
5cb87968aad5 Reworked the FTP stuff to 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 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
61 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
62 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
63 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
64 """
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 def __init__(self, host="", user="", password="", acct="",
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
66 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
67 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
68 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
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 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
71
5cb87968aad5 Reworked the FTP stuff to 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 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
73 @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
74 @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
75 @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
76 @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
77 @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
78 @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
79 @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
80 @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
81 @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
82 @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
83 """
2911
ce77f0b1ee67 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525 2872
diff changeset
84 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
85
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
86 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
87
5cb87968aad5 Reworked the FTP stuff to 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.__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
89 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
90 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
91 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
92 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
93 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
94
5cb87968aad5 Reworked the FTP stuff to 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.__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
96 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
97 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
98 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
99 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
100
5cb87968aad5 Reworked the FTP stuff to 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 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
102 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
103 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
104 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
105
5cb87968aad5 Reworked the FTP stuff to 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 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
107 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
108 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
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 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
111
5cb87968aad5 Reworked the FTP stuff to 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 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
113 @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
114 @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
115 @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
116 @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
117 @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
118 """
5cb87968aad5 Reworked the FTP stuff to 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.__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
120 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
121 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
122 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
123 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
124 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
125
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
126 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
127 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
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 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
130
5cb87968aad5 Reworked the FTP stuff to 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 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
132 @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
133 @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
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.__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
136 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
137 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
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 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
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 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
142
5cb87968aad5 Reworked the FTP stuff to 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 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
144 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
145 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
146
5cb87968aad5 Reworked the FTP stuff to 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 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
148 @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
149 @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
150 @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
151 @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
152 """
5cb87968aad5 Reworked the FTP stuff to 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 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
154 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
155 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
156 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
157 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
158 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
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 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
161 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
162 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
163 "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
164
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
165 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
166 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
167 else:
3065
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
168 return super(E5Ftp, self).connect(
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
169 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
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 def login(self, 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
172 """
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 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
174
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
175 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
176 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
177 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
178 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
179
5cb87968aad5 Reworked the FTP stuff to 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 <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
181 <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
182 <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
183 <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
184 <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
185 <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
186 </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
187 </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
188
5cb87968aad5 Reworked the FTP stuff to 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 <dl>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
190 <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
191 <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
192 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
193 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
194 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
195 <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
196 <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
197 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
198 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
199 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
200 <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
201 <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
202 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
203 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
204 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
205 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
206 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
207 <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
208 <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
209 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
210 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
211 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
212 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
213 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
214 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
215 <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
216 <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
217 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
218 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
219 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
220 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
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>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
223 <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
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 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
226 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
227 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
228 <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
229 <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
230 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
231 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
232 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
233 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
234 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
235 <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
236 <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
237 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
238 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
239 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
240 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
241 </dd>
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2074
diff changeset
242 <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
243 <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
244 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
245 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
246 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
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 </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
249
5cb87968aad5 Reworked the FTP stuff to 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 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
251 @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
252 @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
253 @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
254 @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
255 @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
256 """
5cb87968aad5 Reworked the FTP stuff to 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 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
258 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
259 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
260 # 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
261 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
262 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
263 # 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
264 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
265 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
266 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
267
5cb87968aad5 Reworked the FTP stuff to 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 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
269 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
270 # 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
271 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
272 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
273 "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
274 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
275 raise E5FtpProxyError(
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
276 "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
277 " 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
278
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 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
280 E5FtpProxyType.AuthResp,
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2990
diff changeset
281 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
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295 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
296
5cb87968aad5 Reworked the FTP stuff to 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 # 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
298 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
299 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
300 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
301 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
302 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
303 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
304 raise E5FtpProxyError(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
305 "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
306 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
307
5cb87968aad5 Reworked the FTP stuff to 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 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
309 # 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
310 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
311 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
312 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
313 "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
314 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
315 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
316 # 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
317 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
318 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
319 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
320 "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
321 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
322
5cb87968aad5 Reworked the FTP stuff to 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 # 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
324 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
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("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
327 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
328 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
329 if resp[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
330 raise ftplib.error_reply(resp)
5cb87968aad5 Reworked the FTP stuff to 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
5cb87968aad5 Reworked the FTP stuff to 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 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
333 # 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
334 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
335 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
336 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
337 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
338 raise E5FtpProxyError(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2872
diff changeset
339 "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
340 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
341
5cb87968aad5 Reworked the FTP stuff to support a bunch of different FTP proxy types. Unfortunately FTP proxy support is not standardized.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 return resp

eric ide

mercurial