rev 3613 - debbugs-illa
Pierre Habouzit
madcoder at costa.debian.org
Wed Apr 19 18:05:44 UTC 2006
Author: madcoder
Date: 2006-04-19 18:05:44 +0000 (Wed, 19 Apr 2006)
New Revision: 3613
Modified:
debbugs-illa/TODO
debbugs-illa/bzpull.py
Log:
bzpull can now pull informations from multiple bugs.
syntax is e.g. :
./bzpull.py kde 123 , http://bugs.kde.org/456, 789 http://bugs.kde.org/111
it generates a single mail !
Modified: debbugs-illa/TODO
===================================================================
--- debbugs-illa/TODO 2006-04-19 17:42:31 UTC (rev 3612)
+++ debbugs-illa/TODO 2006-04-19 18:05:44 UTC (rev 3613)
@@ -12,9 +12,6 @@
* bzpull:
+ use the db-h spool to query statuses of a bug (forwarded e.g.)
to avoid ldap lag
- + allow bzpull to take multiple actions on the command line, separated
- with commas, à la bts:
- ./bzpull.py kde 1234 , http://bugs.kde.org/1234 , 5678 http://bugs.kde.org/1111
Medium Term:
Modified: debbugs-illa/bzpull.py
===================================================================
--- debbugs-illa/bzpull.py 2006-04-19 17:42:31 UTC (rev 3612)
+++ debbugs-illa/bzpull.py 2006-04-19 18:05:44 UTC (rev 3613)
@@ -30,7 +30,7 @@
###############################################################################
"""
-Usage: %s bzhost [nnn] [http://bugzil.la/NNN]
+Usage: %s bzhost [nnn] [http://bugzil.la/NNN] [, [nnn] [http://bugzil.la/NNN]]
bzhost the bugzilla that is concerned (see /etc/bzlink.cfg)
nnn the debian bug number
@@ -62,63 +62,66 @@
print >> sys.stderr, __doc__.lstrip() % (sys.argv[0].split('/')[-1])
sys.exit(exitCode)
-def prepareMail(bug, rep, needsForwarded):
- url = Cnf.bugzilla()
+def getActions(bug, rep):
+ res = []
- body = "user %s\n" % (Cnf.user())
- if needsForwarded:
- body += "forwarded %s %s/%s\n" % (bug, url, rep.bug)
-
tmp = rep.getStatus()
if tmp is not None:
- body += "usertag %s + bzStatus-%s\n" % (rep.bug, tmp.lower())
+ res.append("usertag %s + bzStatus-%s" % (rep.bug, tmp.lower()))
tmp = rep.getResolution()
if tmp is not None:
- body += "usertag %s + bzRes-%s\n" % (rep.bug, tmp.lower())
+ res.append("usertag %s + bzRes-%s\n" % (rep.bug, tmp.lower()))
- body += "thanks\n"
+ return res
- return body
-
if __name__ == "__main__":
- if len(sys.argv) not in (3, 4): usage(1)
+ if len(sys.argv) < 2:
+ usage(1)
try:
Cnf.setSection(sys.argv[1])
except bzlink.NoSuchSection, s:
die("`%s' is an unknown Bugzilla" % (s))
- bzi = bz.BzInterface(Cnf.bugzilla())
+ bzi = bz.BzInterface(Cnf.bugzilla())
+ btsi = None
- if len(sys.argv) is 3:
- btsi = bts.BtsInterface(Cnf.ldap())
+ actions = ["user %s\n" % (Cnf.user())]
- fwd = False
- bzBug = bzi.bugnumberFromUrl(sys.argv[2])
+ cmds = map(lambda x: x.split('\007'), '\007'.join(sys.argv[2:]).split('\007,\007'))
+ for c in cmds:
+ if len(c) not in (1, 2): usage(1)
+ if len(c) is 1:
+ if btsi is None:
+ btsi = bts.BtsInterface(Cnf.ldap())
- if bzBug is None:
- bug = btsi.getReport(sys.argv[2])
- if bug is None:
- die("#%s does not exists" % (sys.argv[2]))
- bzBug = bzi.bugnumberFromUrl(bug.data['debbugsForwardedTo'][0])
+ bzBug = bzi.bugnumberFromUrl(c[0])
+
if bzBug is None:
- die("#%s does not looks to be forwarded" % (bug.bug))
+ bug = btsi.getReport(c[0])
+ if bug is None:
+ die("#%s does not exists" % (c[0]))
+ bzBug = bzi.bugnumberFromUrl(bug.data['debbugsForwardedTo'][0])
+ if bzBug is None:
+ die("#%s does not looks to be forwarded" % (bug.bug))
+ else:
+ bug = btsi.getReportOfBzBug(Cnf.bugzilla(), bzBug)
+ if bug is None:
+ die("Cannot find any debian bug forwarded to upstream bug %s" % (bzBug))
+
+ actions += getActions(bug.bug, bzi.getReport(bzBug))
else:
- bug = btsi.getReportOfBzBug(Cnf.bugzilla(), bzBug)
- if bug is None:
- die("Cannot find any debian bug forwarded to upstream bug %s" % (bzBug))
+ bzBug = bzi.bugnumberFromUrl(c[1])
+ if bzBug is None: usage(1)
+ actions.append("forwarded %s %s/%s" % (c[0], Cnf.bugzilla(), bzBug))
+ actions += getActions(c[0], bzi.getReport(bzBug))
- bug = bug.bug
- else:
- fwd = True
- bug = sys.argv[2]
- bzBug = bzi.bugnumberFromUrl(sys.argv[3])
+ actions.append("thanks")
- rep = bzi.getReport(bzBug)
mailer = bts.BtsMailer(Cnf.debug())
- msg = mailer.BtsMail(prepareMail(bug, rep, fwd))
+ msg = mailer.BtsMail('\n'.join(actions))
msg['From'] = Cnf.sender()
msg['To'] = 'control at bugs.debian.org'
More information about the pkg-kde-commits
mailing list