[Assorted-commits] SF.net SVN: assorted:[1530] mailing-list-filter/trunk
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-12-29 04:53:03
|
Revision: 1530 http://assorted.svn.sourceforge.net/assorted/?rev=1530&view=rev Author: yangzhang Date: 2009-12-29 04:52:52 +0000 (Tue, 29 Dec 2009) Log Message: ----------- - distinguish between failures requiring logout and failures requiring close - remove procuid - use separate read and write databases in flag_relevant_msgs - fixed: updates to the imap store are also applied to our local cache - release v0.2.1 Modified Paths: -------------- mailing-list-filter/trunk/README mailing-list-filter/trunk/publish.bash mailing-list-filter/trunk/setup.py mailing-list-filter/trunk/src/mlf.py Modified: mailing-list-filter/trunk/README =================================================================== --- mailing-list-filter/trunk/README 2009-12-22 19:20:10 UTC (rev 1529) +++ mailing-list-filter/trunk/README 2009-12-29 04:52:52 UTC (rev 1530) @@ -62,6 +62,10 @@ Changes ------- +v0.2.1 + +- Bug fixes. + v0.2 - Added disk-based operation to remove memory capacity limit. Modified: mailing-list-filter/trunk/publish.bash =================================================================== --- mailing-list-filter/trunk/publish.bash 2009-12-22 19:20:10 UTC (rev 1529) +++ mailing-list-filter/trunk/publish.bash 2009-12-29 04:52:52 UTC (rev 1530) @@ -1,7 +1,7 @@ #!/usr/bin/env bash fullname='Mailing List Filter' -version=0.2 +version=0.2.1 license=gpl3 websrcs=( README ) rels=( pypi: ) Modified: mailing-list-filter/trunk/setup.py =================================================================== --- mailing-list-filter/trunk/setup.py 2009-12-22 19:20:10 UTC (rev 1529) +++ mailing-list-filter/trunk/setup.py 2009-12-29 04:52:52 UTC (rev 1530) @@ -5,7 +5,7 @@ pkg_info_text = """ Metadata-Version: 1.1 Name: mailing-list-filter -Version: 0.2 +Version: 0.2.1 Author: Yang Zhang Author-email: yaaang NOSPAM at REMOVECAPS gmail Home-page: http://assorted.sourceforge.net/mailing-list-filter/ Modified: mailing-list-filter/trunk/src/mlf.py =================================================================== --- mailing-list-filter/trunk/src/mlf.py 2009-12-22 19:20:10 UTC (rev 1529) +++ mailing-list-filter/trunk/src/mlf.py 2009-12-29 04:52:52 UTC (rev 1530) @@ -46,13 +46,24 @@ @contextmanager def login_imap(cfg): info('connecting and logging in') - with networking.logout(imaplib.IMAP4_SSL(cfg.host, cfg.port)) as imap: + imap = imaplib.IMAP4_SSL(cfg.host, cfg.port) + try: imap.login(cfg.user, cfg.passwd) # Close is only valid in the authenticated state. - with closing(imap) as imap: + try: info('selecting mailbox') imap.select(cfg.mailbox) yield imap + except Exception, ex: + try: imap.close() + except imaplib.abort: raise ex + else: + imap.close() + except Exception, ex: + try: imap.logout() + except imaplib.abort: raise ex + else: + imap.logout() # # Functions for fetching messages from the server. @@ -142,8 +153,6 @@ if len(mid2msg.cache) > 1000: mid2msg.sync() mid2msg['maxuid'] = maxuid - # XXX - mid2msg['procuid'] = mid2msg['maxuid'] # # Function for analyzing messages. @@ -218,11 +227,11 @@ # Functions for storing metadata changes back to the server. # -def flag_relevant_msgs(cfg, imap, mid2msg): +def flag_relevant_msgs(cfg, imap, midsrc, mid2msg): info( 'starring/unstarring relevant/irrelevant threads' ) - for msg in itermsgs(mid2msg, 0): + for msg in itermsgs(mid2msg, 0, midsrc): if msg.tid is not None: # is a relevant msgs if r'\Flagged' not in msg.flags: # not already flagged mark_unseen = not cfg.no_mark_unseen and r'\Seen' in msg.flags @@ -231,7 +240,10 @@ msg ) if not cfg.pretend: imap.uid('STORE', msg.uid, '+FLAGS', r'\Flagged') - if mark_unseen: imap.uid('STORE', msg.uid, '-FLAGS', r'\Seen') + msg.flags.append(r'\Flagged') + if mark_unseen: + imap.uid('STORE', msg.uid, '-FLAGS', r'\Seen') + msg.flags.remove(r'\Seen') else: # is not a relevant msg if r'\Flagged' in msg.flags: # was inadvertently flagged mark_seen = not cfg.no_mark_seen and r'\Seen' not in msg.flags @@ -240,7 +252,10 @@ msg ) if not cfg.pretend: imap.uid('STORE', msg.uid, '-FLAGS', r'\Flagged') - if mark_seen: imap.uid('STORE', msg.uid, '+FLAGS', r'\Seen') + msg.flags.remove(r'\Flagged') + if mark_seen: + imap.uid('STORE', msg.uid, '+FLAGS', r'\Seen') + msg.flags.append(r'\Seen') mid2msg['procuid'] = mid2msg['maxuid'] @@ -308,8 +323,12 @@ mark_relevant_threads(cfg) + shutil.copy(dbpath(cfg, 'threaded'), dbpath(cfg, 'flagged')) with login_imap(cfg) as imap: - with closing(opendb(cfg, 'threaded')) as mid2msg: - flag_relevant_msgs(cfg, imap, mid2msg) + with closing(opendb(cfg, 'threaded')) as midsrc: + with closing(opendb(cfg, 'flagged', 'w')) as mid2msg: + flag_relevant_msgs(cfg, imap, midsrc, mid2msg) + os.rename(dbpath(cfg, 'fetched'), dbpath(cfg, 'fetched-old')) + os.rename(dbpath(cfg, 'flagged'), dbpath(cfg, 'fetched')) startup.run_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |