SVN: toys/stbr/src-builder-status.py
beorn
beorn at pld-linux.org
Wed Oct 7 02:04:54 CEST 2009
Author: beorn
Date: Wed Oct 7 02:04:53 2009
New Revision: 10713
Modified:
toys/stbr/src-builder-status.py
Log:
- Switched to Maildir
- Removed no longer valid Big Fat Warning
- Added some TODO, some removed
- Fixed "From" header parsing for Titanium (made by Shadzik)
- Charged with positive energy
Modified: toys/stbr/src-builder-status.py
==============================================================================
--- toys/stbr/src-builder-status.py (original)
+++ toys/stbr/src-builder-status.py Wed Oct 7 02:04:53 2009
@@ -9,17 +9,9 @@
# - DEBUG mode fired from the commandline (getopt?)
# - Status determined from the message sent date, not from the position
# in a mailbox file
-# - Python 2.6 detection and proper message parsing in case of that
-# version (see BIG FAT WARNING below)
-#
-# !!! BIG FAT WARNING !!!
-# The mailbox module has changed in Python 2.6, so this code will stop
-# working FOR SURE. If the Python interpreter on this machine has been
-# upgraded, this script stopped working and you see this big fat warning,
-# then nobody (me?) cared to clean some very important point on the TODO
-# list above. Please send a few grave words to me at beorn at alpha.pl and
-# revert script to the 10018 SVN release.
-# !!! BIG FAT WARNING !!!
+# - Add Message-ID or filename (Maildir) in debug dismantle error
+# message
+# - Add file name in debug "processing message"... message
#
# $Id$
@@ -30,9 +22,9 @@
import sys
-MAILBOX = '/var/mail/stbr'
-ALLOWED_DISTVER = ('th', 'ti')
-ALLOWED_STATUS = ('OK', 'FAILED')
+MAILDIR = '/home/users/stbr/Mail/'
+ALLOWED_DISTVERS = ('th', 'ti')
+ALLOWED_STATUSES = ('OK', 'FAILED')
DEBUG = False # Change this to True in case of disaster to see what is going on
@@ -47,25 +39,29 @@
try:
(distver, spec) = sys.argv[1:3]
distver = distver.lower()
- if distver not in ALLOWED_DISTVER:
+ if distver not in ALLOWED_DISTVERS:
raise Exception()
except:
- sys.stderr.write('Usage: %s { %s } <spec>\n' % (os.path.basename(__file__), ' | '.join(ALLOWED_DISTVER)))
+ sys.stderr.write('Usage: %s { %s } <spec>\n' % (os.path.basename(__file__), ' | '.join(ALLOWED_DISTVERS)))
sys.exit(1)
+builderstr = {
+ 'th': "builder-th-src",
+ 'ti': "builder-ti"
+}[distver]
+
#result = 'UNKNOWN'
result = None
try:
- fh = open(MAILBOX, 'rb')
- mbox = mailbox.UnixMailbox(fh, email_reader_factory)
- for message in mbox:
+ mdir = mailbox.Maildir(MAILDIR, email_reader_factory)
+ for message in mdir:
if not message:
continue
elif DEBUG:
sys.stderr.write('DEBUG: processing message %s\n' % (message['Message-ID'],))
- if not message['From'].endswith('builder-%s-src at pld-linux.org>' % (distver,)):
+ if not message['From'].endswith('%s at pld-linux.org>' % (builderstr)):
continue
for line in message.get_payload().split('\n'):
@@ -76,18 +72,14 @@
if DEBUG:
sys.stderr.write('DEBUG:\tDismantle error at line "%s"\n' % (line,))
continue
- if status not in ALLOWED_STATUS:
+ if status not in ALLOWED_STATUSES:
+ print status
continue
else:
result = status
- fh.close()
except Exception, e:
if DEBUG:
raise
- try:
- fh.close()
- except:
- pass
sys.stdout.write('Script Error\n')
sys.exit(2)
More information about the pld-cvs-commit
mailing list