summaryrefslogtreecommitdiffstats
path: root/pykolab/imap
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-06-12 07:02:16 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-01-17 13:55:19 +0100
commit95e0c4347e93dc1730c43a4732cdfbfcf1165cc4 (patch)
treee98895036e31aa2ed81e744f21cbba2a91798d1d /pykolab/imap
parentc055429f20c5fec1f25219d4c2efdeec00cf510e (diff)
downloadpykolab-95e0c4347e93dc1730c43a4732cdfbfcf1165cc4.tar.gz
When connecting to a specific server, actually connect to that specific server
Calling disconnect() should not traceback should no current connection exist self.namespaces() may not be successful as the user to login as has no mailbox yet (murder) Conflicts: pykolab/imap/__init__.py
Diffstat (limited to 'pykolab/imap')
-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 = {}