From 0f64f93961b479fa02e560ccd12327541de2a45c Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Thu, 27 Sep 2007 11:09:42 +0200 Subject: [PATCH] * massfile: added script to file mass-bugs. * debian/examples, examples/massfile.{instructions,list}: added example files. * setup.py: install massfile. --- debian/changelog | 9 ++ debian/examples | 1 + examples/massfile.instructions | 15 +++ examples/massfile.list | 2 + massfile | 169 ++++++++++++++++++++------------- setup.py | 3 +- 6 files changed, 132 insertions(+), 67 deletions(-) create mode 100644 debian/examples create mode 100644 examples/massfile.instructions create mode 100644 examples/massfile.list diff --git a/debian/changelog b/debian/changelog index 612ed32..0c942fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +ubuntu-dev-tools (0.13) gutsy; urgency=low + + * massfile: added script to file mass-bugs. + * debian/examples, examples/massfile.{instructions,list}: added example + files. + * setup.py: install massfile. + + -- Daniel Holbach Thu, 27 Sep 2007 11:04:52 +0200 + ubuntu-dev-tools (0.12) gutsy; urgency=low * hugdaylist: apply quick fix to not crash. diff --git a/debian/examples b/debian/examples new file mode 100644 index 0000000..e39721e --- /dev/null +++ b/debian/examples @@ -0,0 +1 @@ +examples/* diff --git a/examples/massfile.instructions b/examples/massfile.instructions new file mode 100644 index 0000000..e500b53 --- /dev/null +++ b/examples/massfile.instructions @@ -0,0 +1,15 @@ +subject: [UNMETDEPS] $pack has unmet dependencies +assignee: +subscribers: motu +tags: unmetdeps +text: + A run of + . + LC_ALL=C apt-cache -i unmet | grep ^Package | cut -d' ' -f2 | grep + -v dbgsym | sort -u | xargs apt-cache showsrc | grep ^Directory | + sed 's/Package\:\ //g' | grep verse | cut -d'/' -f4 + indicates that the source package $pack has binary packages that are not + installable (on AMD64) at the moment. + . + Please have a look and make sure it's installable again. + diff --git a/examples/massfile.list b/examples/massfile.list new file mode 100644 index 0000000..f496352 --- /dev/null +++ b/examples/massfile.list @@ -0,0 +1,2 @@ +z88dk +zope-quotafolder diff --git a/massfile b/massfile index ceed51c..6617a4d 100755 --- a/massfile +++ b/massfile @@ -1,81 +1,118 @@ -# Used Martin Pitt's excellent requestsync script, to get this started. +#!/usr/bin/python +# +# (C) Canonical, 2007, GPL v3 -#!/usr/bin/env python +import os +import sys +import email +import subprocess -import os, os.path, sys, subprocess +import launchpadbugs.connector as Connector -subject = "" -assignee = "" -report = "" -pack_list = set() -instructions_file_name = "instructions" -list_file_name = "list" +example_dir = "/usr/share/doc/ubuntu-dev-tools/examples" def read_config(): - global subject, assignee, report - for line in open(os.getcwd()+"/"+instructions_file_name).readlines(): - if line.startswith("subject:"): - subject = line.split("subject: ")[1] - else: - if line.startswith("assignee:"): - assignee = line.split("assignee: ")[1] - else: - report += line + instructions_file = open("instructions") + instructions = email.message_from_file(instructions_file) + instructions_file.close() + instr = dict() + + for field in "subject", "assignee", "subscribers", "tags", "text", \ + "buglist-url": + instr[field] = instructions.get(field) + + return instr def read_list(): - global pack_list - for line in open(os.getcwd()+"/"+list_file_name).readlines(): - if line.strip()!="": - pack_list.add(line.strip("\n")) + pack_list = set() -# -# entry point -# + listfile = open("list") + for line in listfile.readlines(): + if line.strip()!="": + pack_list.add(line.strip("\n")) -if os.path.exists(os.getcwd()+"/"+instructions_file_name): - read_config() -else: - print "%s does not exists." % (os.getcwd()+"/"+instructions_file_name) - sys.exit(1) + listfile.close() + return pack_list + +def file_bug(): + Bug = Connector.ConnectBug() + Bug.authentication = os.path.expanduser("~/.lpcookie") + + +def check_configfiles(): + result = True + + if not os.path.exists("instructions"): + os.system("cp %s/massfile.instructions instructions" % example_dir) + print >> sys.stderr, \ + "No 'instructions' file found. Copied template from %s." % \ + example_dir + result = False + + if not os.path.exists("list"): + os.system("cp %s/massfile.list list" % example_dir) + print >> sys.stderr, \ + "No 'list' file found. Copied template from %s." % example_dir + result = False + + return result + + +def file_bug(config): + Bug = Connector.ConnectBug() + Bug.authentication = os.path.expanduser("~/.lpcookie") + +# try: + bug = Bug.New(product={"name": config["sourcepackage"], "target": "ubuntu"}, + summary=config["subject"], + description=config["text"]) + print "Successfully filed bug %s: http://launchpad.net/bugs/%s" % \ + (bug.bugnumber, bug.bugnumber) + for sub in config["subscribers"].split(","): + if sub.strip("\n").strip(): + bug.subscribers.add(sub.strip("\n").strip()) + for tag in config["tags"].split(","): + if tag.strip("\n").strip(): + bug.tags.append(tag.strip("\n").strip()) + bug.assignee = config["assignee"] + bug.commit() +# except: +# "Bug for '%s' was not filed." % config["sourcepackage"] + +def read_buglist(url): + BugList = Connector.ConnectBugList() + packages = set() + + buglist = BugList(url) + for bug in buglist.bugs: + packages.add(bug.sourcepackage) + + return packages + + +def main(): + if not check_configfiles(): + sys.exit(1) + + if not os.path.exists(os.path.expanduser("~/.lpcookie")): + print >> sys.stderr, \ + "Launchpad cookie not found in ~/.lpcookie." + sys.exit(1) + + config = read_config() + pack_list = read_list() + buglist = read_buglist(config["buglist-url"]) -if os.path.exists(os.getcwd()+"/"+list_file_name): - read_list() -else: - print "%s does not exists." % (os.getcwd()+"/"+list_file_name) - sys.exit(1) + for pack in pack_list: + if pack not in buglist: + config["text"] = config["text"].replace("$pack", pack) + config["subject"] = config["subject"].replace("$pack", pack) + config["sourcepackage"] = pack -for pack in pack_list: - # generate bug report - mailtext = """ affects distros/ubuntu/%s - status confirmed - subscribe %s + file_bug(config) -%s - """ % (pack, assignee, report) - mailtext = mailtext.replace("$pack", pack) - subject = subject.replace("$pack", pack) - - # sign it - sign_command = "gpg" - if os.access("/usr/bin/gnome-gpg", os.X_OK): - sign_command = "gnome-gpg" - - gpg = subprocess.Popen([sign_command, "--clearsign"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) - signed_report = gpg.communicate(mailtext)[0] - assert gpg.returncode == 0 - - # generate email - to = "new@bugs.launchpad.net" - print """To: %s -Subject: %s -%s""" % (to, subject, signed_report) - print "Press enter to file this bug, Control-C to abort" - sys.stdin.readline() +if __name__ == '__main__': + main() - mail_process = subprocess.Popen(["mail", "-s", subject, to], - stdin=subprocess.PIPE, stdout=subprocess.PIPE) - mail_process.communicate(signed_report) - - subject = subject.replace(pack, "$pack") diff --git a/setup.py b/setup.py index 41bcb8a..a19154b 100755 --- a/setup.py +++ b/setup.py @@ -27,7 +27,8 @@ setup(name='ubuntu-dev-tools', 'suspicious-source', 'ppaput', 'requestsync', - 'hugdaylist' + 'hugdaylist', + 'massfile' ], )