summaryrefslogtreecommitdiffstats
path: root/pykolab/imap
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-11-19 10:22:43 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-11-19 10:22:43 +0100
commit1c8e0c420989a5b322cb0605800d0f8299a0e9df (patch)
treec728b05546b8589f3429a9e21ab526c26d63a809 /pykolab/imap
parent3bdd15ce70a1054e66746230e7b6613a447747b1 (diff)
downloadpykolab-1c8e0c420989a5b322cb0605800d0f8299a0e9df.tar.gz
Add a function imap_murder() and use it
Diffstat (limited to 'pykolab/imap')
-rw-r--r--pykolab/imap/__init__.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 343ff10..ac359a0 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -280,6 +280,12 @@ class IMAP(object):
else:
return '/'
+ def imap_murder(self):
+ if hasattr(self.imap, 'murder') and self.imap.murder:
+ return True
+ else:
+ return False
+
def namespaces(self):
"""
Obtain the namespaces.
@@ -474,20 +480,20 @@ class IMAP(object):
self.create_folder(folder_name, server)
# In a Cyrus IMAP Murder topology, wait for the murder to have settled
- if hasattr(self.imap, 'murder') and self.imap.murder:
+ if self.imap_murder():
self.disconnect()
self.connect()
- created = False
- last_log = time.time()
- while not created:
- created = self.has_folder(folder_name)
- if not created:
- if time.time() - last_log > 5:
- log.info(_("Waiting for the Cyrus IMAP Murder to settle..."))
- last_log = time.time()
+ created = False
+ last_log = time.time()
+ while not created:
+ created = self.has_folder(folder_name)
+ if not created:
+ if time.time() - last_log > 5:
+ log.info(_("Waiting for the Cyrus IMAP Murder to settle..."))
+ last_log = time.time()
- time.sleep(0.5)
+ time.sleep(0.5)
_additional_folders = None
@@ -546,7 +552,7 @@ class IMAP(object):
admin_login = conf.get(backend, 'admin_login')
admin_password = conf.get(backend, 'admin_password')
- if backend == "cyrus-imap" and hasattr(self.imap, 'murder') and self.imap.murder:
+ if self.imap_murder():
server = self.user_mailbox_server(folder)
else:
server = None
@@ -562,13 +568,14 @@ class IMAP(object):
(personal, other, shared) = self.namespaces()
success = True
except Exception, errmsg:
- if time.time() - last_log > 5:
+ if time.time() - last_log > 5 and self.imap_murder():
log.debug(_("Waiting for the Cyrus murder to settle... %r") % (errmsg))
last_log = time.time()
if conf.debuglevel > 8:
import traceback
traceback.print_exc()
+
time.sleep(0.5)
for additional_folder in additional_folders.keys():