diff --git a/debian/changelog b/debian/changelog index ba7123f..9e2e02d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +ubuntu-dev-tools (0.121) UNRELEASED; urgency=low + + * harvest, setup.py: install tool that queries Harvest for information + about open opportunities for a given source package. + + -- Daniel Holbach Mon, 21 Mar 2011 12:24:56 +0100 + ubuntu-dev-tools (0.120) unstable; urgency=low [ Felix Geyer ] diff --git a/debian/control b/debian/control index 466251a..77c3772 100644 --- a/debian/control +++ b/debian/control @@ -83,6 +83,8 @@ Description: useful tools for Ubuntu developers report. - grab-merge - grabs a merge from merges.ubuntu.com easily. - grep-merges - search for pending merges from Debian. + - harvest - grabs information about development opportunities from + http://harvest.ubuntu.com - hugdaylist - compile HugDay lists from bug list URLs. - import-bug-from-debian - copy a bug from the Debian BTS to Launchpad - lp-list-bugs - briefly list status of Launchpad bugs. diff --git a/debian/copyright b/debian/copyright index d079cdd..c637b65 100644 --- a/debian/copyright +++ b/debian/copyright @@ -90,6 +90,7 @@ Files: ack-sync doc/get-branches.1 doc/grab-attachments.1 doc/grab-merge.1 + doc/harvest.1 doc/hugdaylist.1 doc/massfile.1 doc/merge-changelog.1 @@ -99,13 +100,14 @@ Files: ack-sync get-branches grab-attachments grab-merge + harvest hugdaylist massfile merge-changelog setup-packaging-environment syncpackage Copyright: 2010, Benjamin Drung - 2007-2010, Canonical Ltd. + 2007-2011, Canonical Ltd. 2010, Dustin Kirkland 2008, Jonathan Patrick Davies 2008-2010, Martin Pitt diff --git a/doc/harvest.1 b/doc/harvest.1 new file mode 100644 index 0000000..44b3db0 --- /dev/null +++ b/doc/harvest.1 @@ -0,0 +1,19 @@ +.TH harvest 1 "March 21, 2011" "ubuntu-dev-tools" + +.SH NAME +harvest \- grabs information about a given source package from harvest.ubuntu.com. + +.SH SYNOPSIS +\fBharvest\fP <\fIsource package name\fP> + +.SH DESCRIPTION +\fBharvest\fP is a script that downloads information about development +opportunities from harvest.ubuntu.com and gives a summary of the types of +opportunities. + +.SH AUTHORS +\fBharvest\fP and its manpage were written by Daniel Holbach +. +.PP +Both are released under the GNU General Public License, version 3 or +later. diff --git a/harvest b/harvest new file mode 100755 index 0000000..0c92cf4 --- /dev/null +++ b/harvest @@ -0,0 +1,83 @@ +#!/usr/bin/python + +# Copyright (C) 2011 Canonical Ltd., Daniel Holbach +# +# ################################################################## +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# See file /usr/share/common-licenses/GPL-3 for more details. +# +# ################################################################## +# +# +# harvest - grabs information about development opportunities from +# harvest.ubuntu.com +# +# hugdaylist +# - produces lists like +# https://wiki.ubuntu.com/UbuntuBugDay/20070912?action=raw +# +# hugdaylist -n +# - will only list URLs. + +# Daniel Holbach +# (c) 2011 Canonical + +from optparse import OptionParser +import urllib2 +import json +import sys + +BASE_URL = "http://harvest.ubuntu.com/" +URL_STUB = BASE_URL + "opportunities/json/" + +def opportunity_summary(data): + l = [] + for key in filter(lambda a: a != "total", data.keys()): + l += ["%s (%s)" % (key, data[key])] + return ", ".join(l) + +def main(): + usage = "usage: %prog source-package-name" + opt_parser = OptionParser(usage) + (options, args) = opt_parser.parse_args() + if not args: + opt_parser.print_help() + sys.exit(1) + pkg = sys.argv[1] + url = URL_STUB + pkg.strip() + try: + sock = urllib2.urlopen(url) + except IOError, e: + try: + urllib2.urlopen(BASE_URL) + except urllib2.URLError, _e: + print >> sys.stderr, "Harvest is down." + sys.exit(1) + print "There is no information in Harvest about package '%s'." % pkg + sys.exit(1) + response = sock.read() + sock.close() + data = json.loads(response) + print >> sys.stdout, \ +"""%s has %s opportunities: %s +Find out more: %sopportunities/package/%s""" % (pkg, + data["total"], + opportunity_summary(data), + BASE_URL, + pkg) + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + print >> sys.stderr, "Aborted." + sys.exit(1) diff --git a/setup.py b/setup.py index a262e7c..d2374c8 100755 --- a/setup.py +++ b/setup.py @@ -26,6 +26,7 @@ scripts = ['404main', 'grab-attachments', 'grab-merge', 'grep-merges', + 'harvest', 'hugdaylist', 'import-bug-from-debian', 'lp-list-bugs',