diff options
| author | rixx <rixx-git@cutebit.de> | 2015-03-15 01:31:27 +0100 |
|---|---|---|
| committer | rixx <rixx-git@cutebit.de> | 2015-03-15 01:31:27 +0100 |
| commit | 715d4c521219740b78736471591e39a0be58f786 (patch) | |
| tree | bdc93b97943e869d65f2a7714f5c602c1e556eed | |
| parent | 00e4ef6b7be7f62521caca09defe44cd72e3cab2 (diff) | |
| parent | 7c861be75335f9542e847272aa8a4c9d4f0f079b (diff) | |
Merge branch 'master' into short_mail
| -rw-r--r-- | py3status/modules/imap.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/py3status/modules/imap.py b/py3status/modules/imap.py index 017bb3b..cace8bd 100644 --- a/py3status/modules/imap.py +++ b/py3status/modules/imap.py @@ -1,7 +1,8 @@ # -*- coding: utf8 -*- """ Module displaying the number of unread messages -on an IMAP inbox (configurable). +on an IMAP inbox (configurable, may also be a +comma-separated list of IMAP folders). @author obb """ @@ -46,13 +47,19 @@ class Py3status: def _get_mail_count(self): try: - connection = imaplib.IMAP4_SSL(self.imap_server, self.port) - connection.login(self.user, self.password) - connection.select(self.mailbox) - unseen_response = connection.search(None, self.criterion) - mails = unseen_response[1][0].split() - mail_count = len(mails) + mail_count = 0 + directories = self.mailbox.split(',') + + for directory in directories: + connection = imaplib.IMAP4_SSL(self.imap_server, self.port) + connection.login(self.user, self.password) + connection.select(directory) + unseen_response = connection.search(None, self.criterion) + connection.close() + mails = unseen_response[1][0].split() + mail_count += len(mails) return mail_count + except: return 'N/A' |
