jvc / cleanup-maildir Goto Github PK
View Code? Open in Web Editor NEWcleanup-maildir python script that works with python 2.4 and >=2.5
cleanup-maildir python script that works with python 2.4 and >=2.5
The cleanup-maildir py script floating around on the net did not work with a host I read mail on that runs python 2.5.2. I patched it, then a week later realized that , then realized I also read mail on a box that only has python 2.4. So this now works with both. Note that using 'INBOX' refers to your root maildir (~/Maildir) Example usage: cleanup-maildir -d 1 --age=120 --archive-folder=Archive archive INBOX cleanup-maildir -d 1 --age=90 --archive-folder=Archive.src archive src
Hi,
I'm having this problem with cleanup-maildir when i run it on a large folder of mail, i get this error:
Traceback (most recent call last):
File "./cleanup-maildir", line 504, in
cleaner.clean(mode, dir, minAge)
File "./cleanup-maildir", line 405, in clean
self.log(logging.DEBUG, "Keeping #%d (fresh)" % i, msg)
File "./cleanup-maildir", line 410, in log
subj = msgObj.getSubject()
File "./cleanup-maildir", line 209, in getSubject
email.Header.decode_header(s)))
File "/usr/lib/python2.6/email/header.py", line 101, in decode_header
raise HeaderParseError
email.errors.HeaderParseError
i added some debug code, to try and get more info, but I'm no expert in python so i'm a bit lost as to how i might get more info.
i changed the code to read:
def getSubject(self):
"""get the message's subject as a unicode string"""
import email.Header
s = self.getheader("Subject")
try:
print "DEBUG: subject=", s
return u"".join(map(lambda x: x[0].decode(x[1] or 'ASCII', 'replace'),
email.Header.decode_header(s)))
except(LookupError):
return s
except:
print "Unexpected error:", sys.exc_info()[0]
print "email.Header.decode_header(s) s =", s
raise
also note -
here is my debug output
INFO:MaildirCleaner:(Not really) Archiving #18127 to a Reference.2007: TCF: UNS: Segfault in Samba
DEBUG: subject= eBay Favourite Search: m-audio
INFO:MaildirCleaner:(Not really) Archiving #18128 to a Reference.2007: eBay Favourite Search: m-audio
DEBUG: subject= Updated barcodes showing essdale park counter stand with barcode
DEBUG: subject= =?UTF-8?B?VGhhbmsgeW91IGZvciB5b3VyIGZlZWRi?==?UTF-8?B?YWNr?=
Unexpected error: <class 'email.errors.HeaderParseError'>
email.Header.decode_header(s) s = =?UTF-8?B?VGhhbmsgeW91IGZvciB5b3VyIGZlZWRi?==?UTF-8?B?YWNr?=
see how the header is funny for the last one that seems to cause the error?
any suggestions?
Jason
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.