2 imap_check.py - An imap folder checker
4 Copyright 2006 Kenneth Hayber <ken@hayber.us>,
10 from checker
import Checker
11 class POPChecker(Checker
):
12 def __init__(self
, config
=None):
13 Checker
.__init
__(self
, config
)
16 self
.server
= config
['server']
17 self
.port
= int(config
['port'])
18 self
.username
= config
['username']
19 self
.password
= config
['password']
20 self
.ssl
= (config
['ssl'] == 'True')
21 self
.apop
= (config
['apop'] == 'True')
23 self
.server
= 'localhost'
30 self
.uidls
= [] # list of uidls from last check
31 # save this to a file to prevent all messages being 'new' at startup
38 pop
= poplib
.POP3_SSL(self
.server
)
40 pop
= poplib
.POP3(self
.server
)
43 pop
.apop(self
.username
, self
.password
)
45 pop
.user(self
.username
)
46 pop
.pass_(self
.password
)
48 self
.results
= "%s (%s)\n" % (self
.name
, _('Login Error'))
49 self
.blocker
.trigger()
52 # get list of unique message ids
57 # remove the unneeded parts from the uidl results (just want the uidls)
58 uidls
= map(lambda a
: a
.split()[1], m
[1])
61 # find the new (unseen) uidls
63 if not x
in self
.uidls
:
68 self
.results
= "%s (%d/%d)\n" % (self
.name
, self
.unseen
, len(uidls
))
73 self
.blocker
.trigger()