path: root/pykolab/imap/
diff options
authorLiutauras Adomaitis <>2018-03-15 16:17:38 +0200
committerLiutauras Adomaitis <>2018-05-17 09:56:05 +0300
commit10f1c173941d0a8df227822ca4b497398eb73760 (patch)
tree9a10c7d3fca5ffc5bf7bbfc383d01f9ac36cdaab /pykolab/imap/
parentae2ba60049a4e5c4e4ea427dfb59a63547a683ea (diff)
With this patch I'm trying to introduce a file-type object in logger, which could swallow everything thrown to stderr (and possibly stdout) and redirect to python logger. Python smtplib debug mode prints everything to stderr, but when wallace runs...
Summary: fork mode stderr is not available (Bad file descriptor error) and thus wallace traceback when it tries to send emails Test Plan: none Reviewers: vanmeeuwen, machniak, petersen Reviewed By: vanmeeuwen Subscribers: petersen, machniak, vanmeeuwen Maniphest Tasks: T2498, T2163, T3751 Differential Revision:
Diffstat (limited to 'pykolab/imap/')
1 files changed, 12 insertions, 1 deletions
diff --git a/pykolab/imap/ b/pykolab/imap/
index 27f889b..9907c44 100644
--- a/pykolab/imap/
+++ b/pykolab/imap/
@@ -90,6 +90,11 @@ class Cyrus(cyruslib.CYRUS):
if conf.debuglevel > 8:
self.VERBOSE = True
self.m.debug = 5
+ sl = pykolab.logger.StderrToLogger(log)
+ # imaplib debug outputs everything to stderr. Redirect to Logger
+ sys.stderr = sl
+ # cyruslib debug outputs everything to LOGFD. Redirect to Logger
+ self.LOGFD = sl
# Initialize our variables
self.separator = self.SEP
@@ -139,7 +144,13 @@ class Cyrus(cyruslib.CYRUS):
Login to the Cyrus IMAP server through cyruslib.CYRUS, but set our
hierarchy separator.
- cyruslib.CYRUS.login(self, *args, **kw)
+ try:
+ cyruslib.CYRUS.login(self, *args, **kw)
+ except cyruslib.CYRUSError, errmsg:
+ log.error("Login to Cyrus IMAP server failed: %r", errmsg)
+ except Exception, errmsg:
+ log.exception(errmsg)
self.separator = self.SEP