mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
revert harvest addition for now - no time to add: lacking a man page, a license header, needs to be mentioned in d/control, d/copyright
This commit is contained in:
parent
ad837ae9cf
commit
5b7535a628
7
debian/changelog
vendored
7
debian/changelog
vendored
@ -1,10 +1,3 @@
|
||||
ubuntu-dev-tools (0.115) 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> Wed, 26 Jan 2011 09:21:43 +0100
|
||||
|
||||
ubuntu-dev-tools (0.114) unstable; urgency=low
|
||||
|
||||
[ Stefano Rivera ]
|
||||
|
51
harvest
51
harvest
@ -1,51 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# Daniel Holbach
|
||||
# (c) 2011 Canonical
|
||||
|
||||
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():
|
||||
if len(sys.argv) == 1 or not sys.argv[1].strip() or \
|
||||
sys.argv[1].strip() in ["--help", "-h"]:
|
||||
print >> sys.stderr, "Usage: %s <source package name>" % sys.argv[0]
|
||||
sys.exit(0)
|
||||
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)
|
Loading…
x
Reference in New Issue
Block a user