harvest, setup.py: install tool that queries Harvest for information

about open opportunities for a given source package.
This commit is contained in:
Daniel Holbach 2011-03-21 12:39:25 +01:00
parent 63a99bb3bc
commit 343d5e97b4
6 changed files with 115 additions and 1 deletions

7
debian/changelog vendored
View File

@ -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 <daniel.holbach@ubuntu.com> Mon, 21 Mar 2011 12:24:56 +0100
ubuntu-dev-tools (0.120) unstable; urgency=low ubuntu-dev-tools (0.120) unstable; urgency=low
[ Felix Geyer ] [ Felix Geyer ]

2
debian/control vendored
View File

@ -83,6 +83,8 @@ Description: useful tools for Ubuntu developers
report. report.
- grab-merge - grabs a merge from merges.ubuntu.com easily. - grab-merge - grabs a merge from merges.ubuntu.com easily.
- grep-merges - search for pending merges from Debian. - 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. - hugdaylist - compile HugDay lists from bug list URLs.
- import-bug-from-debian - copy a bug from the Debian BTS to Launchpad - import-bug-from-debian - copy a bug from the Debian BTS to Launchpad
- lp-list-bugs - briefly list status of Launchpad bugs. - lp-list-bugs - briefly list status of Launchpad bugs.

4
debian/copyright vendored
View File

@ -90,6 +90,7 @@ Files: ack-sync
doc/get-branches.1 doc/get-branches.1
doc/grab-attachments.1 doc/grab-attachments.1
doc/grab-merge.1 doc/grab-merge.1
doc/harvest.1
doc/hugdaylist.1 doc/hugdaylist.1
doc/massfile.1 doc/massfile.1
doc/merge-changelog.1 doc/merge-changelog.1
@ -99,13 +100,14 @@ Files: ack-sync
get-branches get-branches
grab-attachments grab-attachments
grab-merge grab-merge
harvest
hugdaylist hugdaylist
massfile massfile
merge-changelog merge-changelog
setup-packaging-environment setup-packaging-environment
syncpackage syncpackage
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com> Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
2007-2010, Canonical Ltd. 2007-2011, Canonical Ltd.
2010, Dustin Kirkland <kirkland@ubuntu.com> 2010, Dustin Kirkland <kirkland@ubuntu.com>
2008, Jonathan Patrick Davies <jpds@ubuntu.com> 2008, Jonathan Patrick Davies <jpds@ubuntu.com>
2008-2010, Martin Pitt <martin.pitt@canonical.com> 2008-2010, Martin Pitt <martin.pitt@canonical.com>

19
doc/harvest.1 Normal file
View File

@ -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
<daniel.holbach@ubuntu.com>.
.PP
Both are released under the GNU General Public License, version 3 or
later.

83
harvest Executable file
View File

@ -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 <url>
# - produces lists like
# https://wiki.ubuntu.com/UbuntuBugDay/20070912?action=raw
#
# hugdaylist -n <howmany> <url>
# - will only list <howmany> 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)

View File

@ -26,6 +26,7 @@ scripts = ['404main',
'grab-attachments', 'grab-attachments',
'grab-merge', 'grab-merge',
'grep-merges', 'grep-merges',
'harvest',
'hugdaylist', 'hugdaylist',
'import-bug-from-debian', 'import-bug-from-debian',
'lp-list-bugs', 'lp-list-bugs',