commit
896ac98984
@ -89,16 +89,15 @@ class UsefulIMAPMixIn:
|
|||||||
return self._open_socket_for_af(self.af)
|
return self._open_socket_for_af(self.af)
|
||||||
|
|
||||||
def _open_socket_for_af(self, af):
|
def _open_socket_for_af(self, af):
|
||||||
msg = (-1, 'could not open socket')
|
|
||||||
for res in socket.getaddrinfo(self.host, self.port, af, socket.SOCK_STREAM):
|
for res in socket.getaddrinfo(self.host, self.port, af, socket.SOCK_STREAM):
|
||||||
af, socktype, proto, canonname, sa = res
|
af, socktype, proto, canonname, sa = res
|
||||||
try:
|
try:
|
||||||
# use socket of our own, possiblly socksified socket.
|
# use socket of our own, possibly SOCKS socket.
|
||||||
s = self.socket(af, socktype, proto)
|
s = self.socket(af, socktype, proto)
|
||||||
except socket.error as msg:
|
except socket.error:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
for i in (0, 1):
|
for _ in (0, 1):
|
||||||
try:
|
try:
|
||||||
s.connect(sa)
|
s.connect(sa)
|
||||||
break
|
break
|
||||||
@ -106,12 +105,14 @@ class UsefulIMAPMixIn:
|
|||||||
if len(msg.args) < 2 or msg.args[0] != errno.EINTR:
|
if len(msg.args) < 2 or msg.args[0] != errno.EINTR:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
msg = (-1, 'could not open socket')
|
||||||
raise socket.error(msg)
|
raise socket.error(msg)
|
||||||
except socket.error as msg:
|
except socket.error:
|
||||||
s.close()
|
s.close()
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
msg = (-1, 'could not open socket')
|
||||||
raise socket.error(msg)
|
raise socket.error(msg)
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
@ -677,6 +677,13 @@ class IMAPServer:
|
|||||||
"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])
|
||||||
|
elif e.args and \
|
||||||
|
e.args[0][:35] == 'IMAP4 protocol error: socket error:':
|
||||||
|
raise OfflineImapError(
|
||||||
|
"Could not connect to remote server '{}' "
|
||||||
|
"for repository '{}'. Connection Refused.".format(
|
||||||
|
self.hostname, self.repos),
|
||||||
|
OfflineImapError.ERROR.CRITICAL)
|
||||||
else:
|
else:
|
||||||
# re-raise all other errors
|
# re-raise all other errors
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user