mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-04-16 12:51:08 +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
6
buildd
6
buildd
@ -124,7 +124,11 @@ if not options.batch:
|
||||
sys.exit(1)
|
||||
|
||||
# Get the ubuntu archive
|
||||
ubuntu_archive = Distribution('ubuntu').getArchive()
|
||||
try:
|
||||
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.
|
||||
try:
|
||||
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
|
||||
|
||||
[ Iain Lane ]
|
||||
|
@ -53,39 +53,52 @@ class BackportFromLP:
|
||||
|
||||
def __prepare_sources(self):
|
||||
# Scrape the source package from Launchpad :)
|
||||
contents = urllib2.urlopen('https://launchpad.net/ubuntu/%(target_release)s/+source/%(package)s' % self).read()
|
||||
links = re.findall('href=\"(.*\.dsc)\"', contents)
|
||||
try:
|
||||
contents = urllib2.urlopen('https://launchpad.net/ubuntu/%(target_release)s/+source/%(package)s' % self).read()
|
||||
links = re.findall('href=\"(.*\.dsc)\"', contents)
|
||||
|
||||
if len(links) == 1 and \
|
||||
subprocess.call(['dget', '-xu', 'https://launchpad.net%s' % links[0]]) == 0:
|
||||
print '\nSuccess!'
|
||||
else:
|
||||
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 len(links) == 1 and \
|
||||
subprocess.call(['dget', '-xu', 'https://launchpad.net%s' % links[0]]) == 0:
|
||||
print '\nSuccess!'
|
||||
else:
|
||||
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.'
|
||||
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__':
|
||||
usage = "Usage: %prog <package> [release]"
|
||||
optParser = OptionParser(usage)
|
||||
(options, args) = optParser.parse_args()
|
||||
release = None
|
||||
|
||||
if not args: optParser.error("Arguments required.")
|
||||
|
||||
package = str(args[0]).lower()
|
||||
|
||||
if len(args) == 2: # Custom distribution specified.
|
||||
release = str(args[1]).lower()
|
||||
else:
|
||||
release = os.getenv('DIST') or Distribution('ubuntu').getDevelopmentSeries().name
|
||||
|
||||
# Arguments are correct, proceed.
|
||||
# Check that the Ubuntu release and package specified exists.
|
||||
try:
|
||||
if len(args) == 2: # Custom distribution specified.
|
||||
release = str(args[1]).lower()
|
||||
else:
|
||||
release = os.getenv('DIST') or Distribution('ubuntu').getDevelopmentSeries().name
|
||||
|
||||
# Arguments are correct, proceed.
|
||||
# Check that the Ubuntu release and package specified exists.
|
||||
Distribution('ubuntu').getArchive().getSourcePackage(package, release)
|
||||
except IOError, e:
|
||||
print "This is non-fatal, continuing..."
|
||||
except (SeriesNotFoundException, PackageNotFoundException), e:
|
||||
print e
|
||||
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...
|
||||
try:
|
||||
print 'Attempting to get %s from release %s...' % \
|
||||
|
@ -76,6 +76,11 @@ if __name__ == '__main__':
|
||||
if options.lpapi:
|
||||
from ubuntutools.requestsync.lp import *
|
||||
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:
|
||||
from ubuntutools.requestsync.mail import *
|
||||
if not getEmailAddress():
|
||||
|
@ -43,7 +43,7 @@ class Launchpad(object):
|
||||
self.__lp = libsupport.get_launchpad('ubuntu-dev-tools')
|
||||
except IOError, error:
|
||||
print >> sys.stderr, 'E: %s' % error
|
||||
sys.exit(1)
|
||||
raise error
|
||||
return self
|
||||
|
||||
def __getattr__(self, attr):
|
||||
|
Loading…
x
Reference in New Issue
Block a user