| 1 |
#!/usr/bin/python
|
| 2 |
|
| 3 |
# Copyright (C) 2001 Martin Michlmayr <tbm@cyrius.com>
|
| 4 |
|
| 5 |
# This program is free software; you can redistribute it and/or modify
|
| 6 |
# it under the terms of the GNU General Public License as published by
|
| 7 |
# the Free Software Foundation; either version 2 of the License, or
|
| 8 |
# (at your option) any later version.
|
| 9 |
|
| 10 |
# This program is distributed in the hope that it will be useful,
|
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
# GNU General Public License for more details.
|
| 14 |
|
| 15 |
# You should have received a copy of the GNU General Public License
|
| 16 |
# along with this program; if not, write to the Free Software
|
| 17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 18 |
|
| 19 |
|
| 20 |
import os, sys, rfc822, time, re, string, StringIO, status
|
| 21 |
|
| 22 |
maint = os.environ['LOCAL_PART'][4:] # skip the 'mia-' part
|
| 23 |
|
| 24 |
mail = StringIO.StringIO(sys.stdin.read())
|
| 25 |
msg = rfc822.Message(mail)
|
| 26 |
|
| 27 |
if string.find(msg.get('Subject'), "MIA-SUMMARY") >= 0:
|
| 28 |
msg.rewindbody()
|
| 29 |
summary = None
|
| 30 |
id = None
|
| 31 |
for line in msg.fp.readlines():
|
| 32 |
|
| 33 |
if summary is None:
|
| 34 |
summary = re.search("MIA-Summary:\s*(.+)", line, re.I)
|
| 35 |
|
| 36 |
if id is None:
|
| 37 |
id = re.search("MIA-ID:\s*(\d+)", line, re.I)
|
| 38 |
|
| 39 |
if (summary and id) is not None:
|
| 40 |
status.write_status(maint, id.group(0), summary.group(0))
|
| 41 |
|
| 42 |
try:
|
| 43 |
sendmail = os.popen('/usr/sbin/sendmail -oi -t', 'w')
|
| 44 |
except IOError:
|
| 45 |
print 'Cannot open sendmail'
|
| 46 |
sys.exit(1)
|
| 47 |
|
| 48 |
mail_message = """Return-Path: mia@qa.debian.org
|
| 49 |
From: Martin Michlmayr and others <mia-%s@qa.debian.org>
|
| 50 |
To: mia@qa.debian.org
|
| 51 |
Subject: thanks for the summary
|
| 52 |
In-Reply-To: %s
|
| 53 |
References: %s %s
|
| 54 |
|
| 55 |
Thanks for adding the following summary for '%s':
|
| 56 |
|
| 57 |
MIA-Summary: %s
|
| 58 |
MIA-ID: %s
|
| 59 |
|
| 60 |
""" % (maint, msg.get('Message-ID'), msg.get('References'),
|
| 61 |
msg.get('Message-ID'), maint, summary.groups()[0], id.groups()[0])
|
| 62 |
|
| 63 |
sendmail.write(mail_message)
|
| 64 |
sendmail.close()
|
| 65 |
|
| 66 |
else:
|
| 67 |
print "not ok: no summary or ID"
|
| 68 |
sys.exit(1)
|
| 69 |
|
| 70 |
else:
|
| 71 |
try:
|
| 72 |
mbox = open(status.origin + '/' + maint, 'a')
|
| 73 |
except IOError:
|
| 74 |
print "Cannot open mbox file for %s to append!" % maint
|
| 75 |
sys.exit(1)
|
| 76 |
|
| 77 |
mbox.write(mail.getvalue())
|
| 78 |
mbox.close()
|
| 79 |
|
| 80 |
try:
|
| 81 |
sendmail = os.popen('/usr/sbin/sendmail -oi -t', 'w')
|
| 82 |
except IOError:
|
| 83 |
print 'Cannot open sendmail'
|
| 84 |
sys.exit(1)
|
| 85 |
|
| 86 |
date = msg.getdate("Date")
|
| 87 |
when = int(time.mktime(date))
|
| 88 |
|
| 89 |
mail_message = """Return-Path: mia@qa.debian.org
|
| 90 |
From: Martin Michlmayr and others <mia-%s@qa.debian.org>
|
| 91 |
To: mia@qa.debian.org
|
| 92 |
Reply-To: mia-%s@qa.debian.org
|
| 93 |
""" % (maint, maint)
|
| 94 |
|
| 95 |
summary = msg.get('X-MIA-Summary')
|
| 96 |
|
| 97 |
if summary:
|
| 98 |
status.write_status(maint, when, summary)
|
| 99 |
mail_message = mail_message + """Subject: Added: %s
|
| 100 |
|
| 101 |
Summary: %s
|
| 102 |
""" % (msg.get('Subject'), summary)
|
| 103 |
|
| 104 |
else:
|
| 105 |
mail_message = mail_message + """Subject: MIA-SUMMARY %s
|
| 106 |
In-Reply-To: %s
|
| 107 |
References: %s %s
|
| 108 |
|
| 109 |
Please respond with a summary and leave the ID intact.
|
| 110 |
|
| 111 |
MIA-Summary:
|
| 112 |
MIA-ID: %s
|
| 113 |
|
| 114 |
Some possible summaries include: initial contact, willfix, willorphan,
|
| 115 |
needs help, active, removed
|
| 116 |
""" % (msg.get('Subject'), msg.get('Message-ID'), msg.get('References'),,
|
| 117 |
msg.get('Message-ID'), when)
|
| 118 |
|
| 119 |
|
| 120 |
mail_message = mail_message + """
|
| 121 |
----------------------------------------------------------------
|
| 122 |
|
| 123 |
From: %s
|
| 124 |
Date: %s
|
| 125 |
|
| 126 |
""" % (msg.get('From'), msg.get('Date'))
|
| 127 |
|
| 128 |
sendmail.write(mail_message)
|
| 129 |
msg.rewindbody()
|
| 130 |
for line in msg.fp.readlines():
|
| 131 |
sendmail.write(line)
|
| 132 |
sendmail.close()
|
| 133 |
|