rev 3584 - scripts
Pierre Habouzit
madcoder at costa.debian.org
Tue Apr 18 13:05:37 UTC 2006
Author: madcoder
Date: 2006-04-18 13:05:36 +0000 (Tue, 18 Apr 2006)
New Revision: 3584
Modified:
scripts/bzsync.py
Log:
use bugzilla XML api to query for bug status.
also fix some glitches
Modified: scripts/bzsync.py
===================================================================
--- scripts/bzsync.py 2006-04-18 11:35:59 UTC (rev 3583)
+++ scripts/bzsync.py 2006-04-18 13:05:36 UTC (rev 3584)
@@ -36,45 +36,42 @@
"""
import sys, re, os, commands, email, smtplib
+from xml.dom import minidom, Node
from email.MIMEText import MIMEText
from bzlink import BtsQuery, Config
-wget = "wget -o /dev/null -O - %s | egrep '<b>(Status|Resolution)'"
-bugurl1 = re.compile(r"^http://bugs.kde.org/([0-9]*)$")
-bugurl2 = re.compile(r"^http://bugs.kde.org/show_bug.cgi\?id=([0-9]*)$")
+wget = "wget -o /dev/null -O - http://bugs.kde.org/xml.cgi?id=%s"
+bugurl = re.compile(r"^http://bugs.kde.org/(?:show_bug.cgi\?id=)?([0-9]*)$")
def usage(exitCode = 1):
print >> sys.stderr, (__doc__ % (sys.argv[0].split('/')[-1]))
sys.exit(exitCode)
-def prepareMail(bug, url, needsForwarded):
- flags = commands.getoutput(wget % (url))
- flags = re.sub(r"<[^<]*>", "", flags)
-
-
+def prepareMail(bug, bzBug, needsForwarded):
body = "user %s\n" % (Config.User)
if needsForwarded:
- body += "forwarded %s %s\n" % (bug, url)
+ body += "forwarded %s http://bugs.kde.org/%s\n" % (bug, bzBug)
body += "usertag %s =\n" % (bug)
- for l in flags.splitlines():
- k, v = l.split(':')
- if k == 'Status':
- body += "usertag %s + bzStatus-%s\n" % (bug, v.lower())
- if k == 'Resolution':
- body += "usertag %s + bzRes-%s\n" % (bug, v.lower())
- body += "thanks\n"
+
+ doc = minidom.parseString(commands.getoutput(wget % (bzBug)))
+ status = doc.getElementsByTagName('bug_status')[0].childNodes[0].data
+ body += "usertag %s + bzStatus-%s\n" % (bug, status.lower())
+ try:
+ resol = doc.getElementsByTagName('resolution')[0].childNodes[0].data
+ body += "usertag %s + bzRes-%s\n" % (bug, resol.lower())
+ except:
+ pass
+ doc.unlink()
+
return body
if __name__ == "__main__":
url = sys.argv[-1]
fwd = True
- m = bugurl1.match(url)
- if not m:
- m = bugurl2.match(url)
- elif not m:
- usage(1)
+ m = bugurl.match(url)
+ if not m: usage(1)
bzBug = m.group(1)
@@ -90,7 +87,7 @@
bug = sys.argv[1]
else: usage(1)
- msg = MIMEText(prepareMail(bug, url, fwd))
+ msg = MIMEText(prepareMail(bug, bzBug, fwd))
msg['From'] = Config.From
msg['To'] = 'control at bugs.debian.org'
msg['X-Debbugs-No-Ack'] = 'no-acks'
More information about the pkg-kde-commits
mailing list