six: changed offlineimap/imapserver.py
This patch removes the library six, compatible with python2. I need change these re-raise calls. Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
This commit is contained in:
		| @@ -27,16 +27,12 @@ from socket import gaierror | |||||||
| from sys import exc_info | from sys import exc_info | ||||||
| from ssl import SSLError, cert_time_to_seconds | from ssl import SSLError, cert_time_to_seconds | ||||||
| from threading import Lock, BoundedSemaphore, Thread, Event, currentThread | from threading import Lock, BoundedSemaphore, Thread, Event, currentThread | ||||||
|  |  | ||||||
| import six |  | ||||||
|  |  | ||||||
| import offlineimap.accounts | import offlineimap.accounts | ||||||
| from offlineimap import imaplibutil, imaputil, threadutil, OfflineImapError | from offlineimap import imaplibutil, imaputil, threadutil, OfflineImapError | ||||||
| from offlineimap.ui import getglobalui | from offlineimap.ui import getglobalui | ||||||
|  |  | ||||||
| try: | try: | ||||||
|     import gssapi |     import gssapi | ||||||
|  |  | ||||||
|     have_gss = True |     have_gss = True | ||||||
| except ImportError: | except ImportError: | ||||||
|     have_gss = False |     have_gss = False | ||||||
| @@ -253,7 +249,8 @@ class IMAPServer(): | |||||||
|                     msg = "%s (configuration is: %s)" % (e, str(params)) |                     msg = "%s (configuration is: %s)" % (e, str(params)) | ||||||
|                 except Exception as eparams: |                 except Exception as eparams: | ||||||
|                     msg = "%s [cannot display configuration: %s]" % (e, eparams) |                     msg = "%s [cannot display configuration: %s]" % (e, eparams) | ||||||
|                 six.reraise(type(e), type(e)(msg), exc_info()[2]) |  | ||||||
|  |                 raise type(e)(msg, exc_info()[2]) | ||||||
|             finally: |             finally: | ||||||
|                 socket.socket = original_socket |                 socket.socket = original_socket | ||||||
|  |  | ||||||
| @@ -633,9 +630,7 @@ class IMAPServer(): | |||||||
|                          "'%s'. Make sure you have configured the ser" \ |                          "'%s'. Make sure you have configured the ser" \ | ||||||
|                          "ver name correctly and that you are online." % \ |                          "ver name correctly and that you are online." % \ | ||||||
|                          (self.hostname, self.repos) |                          (self.hostname, self.repos) | ||||||
|                 six.reraise(OfflineImapError, |                 raise OfflineImapError(reason, severity, exc_info()[2]) | ||||||
|                             OfflineImapError(reason, severity), |  | ||||||
|                             exc_info()[2]) |  | ||||||
|  |  | ||||||
|             elif isinstance(e, SSLError) and e.errno == errno.EPERM: |             elif isinstance(e, SSLError) and e.errno == errno.EPERM: | ||||||
|                 # SSL unknown protocol error |                 # SSL unknown protocol error | ||||||
| @@ -649,9 +644,7 @@ class IMAPServer(): | |||||||
|                     reason = "Unknown SSL protocol connecting to host '%s' for " \ |                     reason = "Unknown SSL protocol connecting to host '%s' for " \ | ||||||
|                              "repository '%s'. OpenSSL responded:\n%s" \ |                              "repository '%s'. OpenSSL responded:\n%s" \ | ||||||
|                              % (self.hostname, self.repos, e) |                              % (self.hostname, self.repos, e) | ||||||
|                 six.reraise(OfflineImapError, |                 raise OfflineImapError(reason, severity, exc_info()[2]) | ||||||
|                             OfflineImapError(reason, severity), |  | ||||||
|                             exc_info()[2]) |  | ||||||
|  |  | ||||||
|             elif isinstance(e, socket.error) and e.args[0] == errno.ECONNREFUSED: |             elif isinstance(e, socket.error) and e.args[0] == errno.ECONNREFUSED: | ||||||
|                 # "Connection refused", can be a non-existing port, or an unauthorized |                 # "Connection refused", can be a non-existing port, or an unauthorized | ||||||
| @@ -660,18 +653,16 @@ class IMAPServer(): | |||||||
|                          "refused. Make sure you have the right host and port " \ |                          "refused. Make sure you have the right host and port " \ | ||||||
|                          "configured and that you are actually able to access the " \ |                          "configured and that you are actually able to access the " \ | ||||||
|                          "network." % (self.hostname, self.port, self.repos) |                          "network." % (self.hostname, self.port, self.repos) | ||||||
|                 six.reraise(OfflineImapError, |                 raise OfflineImapError(reason, severity, exc_info()[2]) | ||||||
|                             OfflineImapError(reason, severity), |  | ||||||
|                             exc_info()[2]) |  | ||||||
|             # Could not acquire connection to the remote; |             # Could not acquire connection to the remote; | ||||||
|             # socket.error(last_error) raised |             # socket.error(last_error) raised | ||||||
|             if str(e)[:24] == "can't open socket; error": |             if str(e)[:24] == "can't open socket; error": | ||||||
|                 six.reraise(OfflineImapError, |                 raise OfflineImapError( | ||||||
|                             OfflineImapError( |                     "Could not connect to remote server '%s' " | ||||||
|                                 "Could not connect to remote server '%s' " |                     "for repository '%s'. Remote does not answer." % (self.hostname, self.repos), | ||||||
|                                 "for repository '%s'. Remote does not answer." % (self.hostname, self.repos), |                     OfflineImapError.ERROR.REPO, | ||||||
|                                 OfflineImapError.ERROR.REPO), |                     exc_info()[2]) | ||||||
|                             exc_info()[2]) |  | ||||||
|             else: |             else: | ||||||
|                 # re-raise all other errors |                 # re-raise all other errors | ||||||
|                 raise |                 raise | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Rodolfo García Peñas (kix)
					Rodolfo García Peñas (kix)