summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pykolab/imap/__init__.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 1bd1f77..e540bc0 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -171,7 +171,7 @@ class IMAP(object):
self._imap[hostname].logged_in = True
else:
- if not login and self._imap[hostname].logged_in == True:
+ if not login:
self.disconnect(hostname)
self.connect(uri=uri,login=False)
elif login and not hasattr(self._imap[hostname],'logged_in'):
@@ -197,7 +197,8 @@ class IMAP(object):
def disconnect(self, server=None):
if server == None:
# No server specified, but make sure self.imap is None anyways
- del self.imap
+ if hasattr(self, 'imap'):
+ del self.imap
else:
if self._imap.has_key(server):
del self._imap[server]
@@ -418,8 +419,21 @@ class IMAP(object):
admin_login = conf.get(backend, 'admin_login')
admin_password = conf.get(backend, 'admin_password')
- self.connect(login=False)
- self.login_plain(admin_login, admin_password, folder)
+ success = False
+ while not success:
+ try:
+
+ self.disconnect()
+ self.connect(login=False)
+ self.login_plain(admin_login, admin_password, folder)
+ (personal, other, shared) = self.namespaces()
+ success = True
+ except Exception, errmsg:
+ log.debug(_("Waiting for the Cyrus murder to settle... %r") % (errmsg))
+ if conf.debuglevel > 8:
+ import traceback
+ traceback.print_exc()
+ time.sleep(0.5)
for additional_folder in additional_folders.keys():
_add_folder = {}