diff options
| author | Ultrabug <ultrabug@ultrabug.net> | 2015-03-16 09:39:35 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@ultrabug.net> | 2015-03-16 09:39:35 +0100 |
| commit | 4fd8bbb9083beb3c939b10bf9c2378fc517c3cbd (patch) | |
| tree | eea7e402c6276de871e3839ea94dd808053c651b | |
| parent | 97b9e8f6af72b8d5970f95369d0717cc65e4c1c1 (diff) | |
| parent | d8bf36f2aa8a190b63f0934bb9ef7039ac5be545 (diff) | |
Merge pull request #77 from rixx/master
IMAP module may now check several IMAP folders by @rixx
| -rw-r--r-- | py3status/modules/imap.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/py3status/modules/imap.py b/py3status/modules/imap.py index d7ce5be..f76f7f9 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 """ @@ -42,13 +43,20 @@ class Py3status: def _get_mail_count(self): try: + mail_count = 0 + directories = self.mailbox.split(',') 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) + + for directory in directories: + connection.select(directory) + unseen_response = connection.search(None, self.criterion) + mails = unseen_response[1][0].split() + mail_count += len(mails) + + connection.close() return mail_count + except: return 'N/A' |
