small fixes and improvements
This commit is contained in:
@@ -4,12 +4,17 @@ from datetime import date
|
||||
from config import Config
|
||||
f=file('config.cfg')
|
||||
cfg=Config(f)
|
||||
server = imapclient.IMAPClient(cfg.host, use_uid=True, ssl=True)
|
||||
server.login(cfg.user, cfg.password)
|
||||
server.select_folder('INBOX')
|
||||
|
||||
try:
|
||||
server = imapclient.IMAPClient(cfg.host, use_uid=True, ssl=True)
|
||||
server.login(cfg.user, cfg.password)
|
||||
server.select_folder('INBOX')
|
||||
except Error:
|
||||
print "error initializing server"
|
||||
server=None
|
||||
|
||||
def fetch_mail(myid):
|
||||
if server is None:
|
||||
raise ValueError("Server is None")
|
||||
m=server.fetch([myid],['ENVELOPE','RFC822'])
|
||||
m=m[myid]
|
||||
m["id"]=myid
|
||||
@@ -19,7 +24,9 @@ def fetch_thread(tp):
|
||||
return tp
|
||||
|
||||
def fetch_threads():
|
||||
src=server.thread(criteria=[b'SUBJECT', b'service', b'SINCE', date(2017,05,01)])
|
||||
if server is None:
|
||||
raise ValueError("Server is None")
|
||||
src=server.thread(criteria=[b'SUBJECT', b'service', b'SINCE', date(2017,02,01)])
|
||||
#, b'BEFORE', date(2017,08,01)
|
||||
return src
|
||||
|
||||
@@ -44,12 +51,17 @@ def store_threads(thrds):
|
||||
if th == None:
|
||||
th=MailThread()
|
||||
th.firstmail=t[0]
|
||||
th.body=yaml.dump(t) # body zb (27422,27506), (27450,)
|
||||
th.islabeled=False
|
||||
th.opened=True
|
||||
th.istrained=False
|
||||
elif not th.body == yaml.dump(t): # Ansonsten body vergleichen
|
||||
th.body=yaml.dump(t) # body zb (27422,27506), (27450,)
|
||||
th.islabeled=False
|
||||
th.opened=True
|
||||
else:
|
||||
th.body=yaml.dump(t)
|
||||
th.istrained=False
|
||||
# else:
|
||||
# th.body=yaml.dump(t)
|
||||
db_session.add(th)
|
||||
db_session.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user