mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-20 21:31:35 +00:00
Conditional LP API usage & better p-l-s errors
* lpapicache: Do not immediately bail out if we have no credentials to login. Clients are now expected to handle the lack of credentials themselves. * pull-lp-source: Make LP API use optional - fall back to a hardcoded default release if we aren't using it. (LP: #477670) * pull-lp-source: Detect more failure conditions and give a nice error instead of a trace * buildd, requestsync: Detect & bail if we don't have credentials and need them. These scripts cannot continue under those circumstances.
This commit is contained in:
parent
e596fad456
commit
6db05720f3
4
buildd
4
buildd
@ -124,7 +124,11 @@ if not options.batch:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Get the ubuntu archive
|
# Get the ubuntu archive
|
||||||
|
try:
|
||||||
ubuntu_archive = Distribution('ubuntu').getArchive()
|
ubuntu_archive = Distribution('ubuntu').getArchive()
|
||||||
|
# Will fail here if we have no credentials, bail out
|
||||||
|
except IOError:
|
||||||
|
sys.exit(1)
|
||||||
# Get list of published sources for package in question.
|
# Get list of published sources for package in question.
|
||||||
try:
|
try:
|
||||||
sources = ubuntu_archive.getSourcePackage(package, release, pocket)
|
sources = ubuntu_archive.getSourcePackage(package, release, pocket)
|
||||||
|
14
debian/changelog
vendored
14
debian/changelog
vendored
@ -1,3 +1,17 @@
|
|||||||
|
ubuntu-dev-tools (0.83) UNRELEASED; urgency=low
|
||||||
|
|
||||||
|
* lpapicache: Do not immediately bail out if we have no credentials to
|
||||||
|
login. Clients are now expected to handle the lack of credentials
|
||||||
|
themselves.
|
||||||
|
* pull-lp-source: Make LP API use optional - fall back to a hardcoded
|
||||||
|
default release if we aren't using it. (LP: #477670)
|
||||||
|
* pull-lp-source: Detect more failure conditions and give a nice error
|
||||||
|
instead of a trace
|
||||||
|
* buildd, requestsync: Detect & bail if we don't have credentials and need
|
||||||
|
them. These scripts cannot continue under those circumstances.
|
||||||
|
|
||||||
|
-- Iain Lane <laney@ubuntu.com> Sat, 07 Nov 2009 19:18:27 +0000
|
||||||
|
|
||||||
ubuntu-dev-tools (0.82) lucid; urgency=low
|
ubuntu-dev-tools (0.82) lucid; urgency=low
|
||||||
|
|
||||||
[ Iain Lane ]
|
[ Iain Lane ]
|
||||||
|
@ -53,6 +53,7 @@ class BackportFromLP:
|
|||||||
|
|
||||||
def __prepare_sources(self):
|
def __prepare_sources(self):
|
||||||
# Scrape the source package from Launchpad :)
|
# Scrape the source package from Launchpad :)
|
||||||
|
try:
|
||||||
contents = urllib2.urlopen('https://launchpad.net/ubuntu/%(target_release)s/+source/%(package)s' % self).read()
|
contents = urllib2.urlopen('https://launchpad.net/ubuntu/%(target_release)s/+source/%(package)s' % self).read()
|
||||||
links = re.findall('href=\"(.*\.dsc)\"', contents)
|
links = re.findall('href=\"(.*\.dsc)\"', contents)
|
||||||
|
|
||||||
@ -63,16 +64,22 @@ class BackportFromLP:
|
|||||||
raise ValueError, '\nFailed to fetch and extract the source. ' +\
|
raise ValueError, '\nFailed to fetch and extract the source. ' +\
|
||||||
'Ensure that the package specified is a valid source ' +\
|
'Ensure that the package specified is a valid source ' +\
|
||||||
'package name and that Launchpad is not down.'
|
'package name and that Launchpad is not down.'
|
||||||
|
except urllib2.HTTPError:
|
||||||
|
raise ValueError, '\nFailed to fetch and extract the source. ' +\
|
||||||
|
'Ensure that the package specified is a valid source ' +\
|
||||||
|
'package name and that Launchpad is not down.'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
usage = "Usage: %prog <package> [release]"
|
usage = "Usage: %prog <package> [release]"
|
||||||
optParser = OptionParser(usage)
|
optParser = OptionParser(usage)
|
||||||
(options, args) = optParser.parse_args()
|
(options, args) = optParser.parse_args()
|
||||||
|
release = None
|
||||||
|
|
||||||
if not args: optParser.error("Arguments required.")
|
if not args: optParser.error("Arguments required.")
|
||||||
|
|
||||||
package = str(args[0]).lower()
|
package = str(args[0]).lower()
|
||||||
|
|
||||||
|
try:
|
||||||
if len(args) == 2: # Custom distribution specified.
|
if len(args) == 2: # Custom distribution specified.
|
||||||
release = str(args[1]).lower()
|
release = str(args[1]).lower()
|
||||||
else:
|
else:
|
||||||
@ -80,12 +87,18 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# Arguments are correct, proceed.
|
# Arguments are correct, proceed.
|
||||||
# Check that the Ubuntu release and package specified exists.
|
# Check that the Ubuntu release and package specified exists.
|
||||||
try:
|
|
||||||
Distribution('ubuntu').getArchive().getSourcePackage(package, release)
|
Distribution('ubuntu').getArchive().getSourcePackage(package, release)
|
||||||
|
except IOError, e:
|
||||||
|
print "This is non-fatal, continuing..."
|
||||||
except (SeriesNotFoundException, PackageNotFoundException), e:
|
except (SeriesNotFoundException, PackageNotFoundException), e:
|
||||||
print e
|
print e
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# We won't have been able to get the release if there are no LP credentials, hardcode it
|
||||||
|
# also could bail out here if others think that is better
|
||||||
|
if release is None:
|
||||||
|
release = 'lucid'
|
||||||
|
|
||||||
# All good - start downloading...
|
# All good - start downloading...
|
||||||
try:
|
try:
|
||||||
print 'Attempting to get %s from release %s...' % \
|
print 'Attempting to get %s from release %s...' % \
|
||||||
|
@ -76,6 +76,11 @@ if __name__ == '__main__':
|
|||||||
if options.lpapi:
|
if options.lpapi:
|
||||||
from ubuntutools.requestsync.lp import *
|
from ubuntutools.requestsync.lp import *
|
||||||
from ubuntutools.lp.lpapicache import Distribution, PersonTeam
|
from ubuntutools.lp.lpapicache import Distribution, PersonTeam
|
||||||
|
# See if we have LP credentials and exit if we don't - cannot continue in this case
|
||||||
|
try:
|
||||||
|
Launchpad.login()
|
||||||
|
except IOError:
|
||||||
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
from ubuntutools.requestsync.mail import *
|
from ubuntutools.requestsync.mail import *
|
||||||
if not getEmailAddress():
|
if not getEmailAddress():
|
||||||
|
@ -43,7 +43,7 @@ class Launchpad(object):
|
|||||||
self.__lp = libsupport.get_launchpad('ubuntu-dev-tools')
|
self.__lp = libsupport.get_launchpad('ubuntu-dev-tools')
|
||||||
except IOError, error:
|
except IOError, error:
|
||||||
print >> sys.stderr, 'E: %s' % error
|
print >> sys.stderr, 'E: %s' % error
|
||||||
sys.exit(1)
|
raise error
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user