pull-lp-source: Catch errors parsing JSON we got from DDE (LP: #1059848)

This commit is contained in:
Stefano Rivera 2012-10-17 22:14:23 +02:00
parent 73461fca08
commit 586197d591
2 changed files with 4 additions and 1 deletions

1
debian/changelog vendored
View File

@ -19,6 +19,7 @@ ubuntu-dev-tools (0.144) UNRELEASED; urgency=low
(LP: #936014)
* ubuntutools.question: Catch EOF and SIGINT on all input and bail out.
(LP: #1037488)
* pull-lp-source: Catch errors parsing JSON we got from DDE (LP: #1059848)
[ Benjamin Drung ]
* seeded-in-ubuntu: State in error message that it takes a source package.

View File

@ -47,12 +47,14 @@ def source_package_for(binary, release):
"""
url = ('http://dde.debian.net/dde/q/udd/dist/d:ubuntu/r:%s/p:%s/?t=json'
% (release, binary))
data = None
try:
data = json.load(urllib2.urlopen(url))['r']
except urllib2.URLError, e:
Logger.error('Unable to retrieve package information from DDE: '
'%s (%s)', url, str(e))
return None
except ValueError:
Logger.error('Unable to parse the response from DDE.')
if not data:
return None
return data[0]['source']