Better fix for #102

Rationale:
-other backends don't require internet access
-displaying last unread count w/o connection seems reasonable
-however: error handling in get_connection() is quite wildcardy,
which is no good. Should be fixed asap.

Introducing a core exception for directly displaying errors may be a good idea at this point for next.
This commit is contained in:
enkore 2014-08-28 13:11:20 +02:00
parent 9cdcfccb6c
commit 75fcad26fd
2 changed files with 3 additions and 4 deletions

View File

@ -41,7 +41,6 @@ class Mail(IntervalModule):
for backend in self.backends: for backend in self.backends:
pass pass
@require(internet)
def run(self): def run(self):
unread = sum(map(lambda backend: backend.unread, self.backends)) unread = sum(map(lambda backend: backend.unread, self.backends))

View File

@ -26,6 +26,7 @@ class IMAP(Backend):
imap_class = imaplib.IMAP4 imap_class = imaplib.IMAP4
connection = None connection = None
last = 0
def init(self): def init(self):
if self.ssl: if self.ssl:
@ -51,9 +52,8 @@ class IMAP(Backend):
def unread(self): def unread(self):
conn = self.get_connection() conn = self.get_connection()
if conn: if conn:
return len(conn.search(None, "UnSeen")[1][0].split()) self.last = len(conn.search(None, "UnSeen")[1][0].split())
else: return self.last
sys.stderr.write("no connection")
Backend = IMAP Backend = IMAP