Tidy pull-lp-source, use Logger

This commit is contained in:
Stefano Rivera 2010-12-24 12:04:46 +02:00
parent 0d51908f40
commit 9033bf7ee7

View File

@ -68,18 +68,21 @@ if __name__ == '__main__':
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:
release = os.getenv('DIST') or Distribution('ubuntu').getDevelopmentSeries().name release = os.getenv('DIST') or (Distribution('ubuntu')
.getDevelopmentSeries().name)
try: try:
(release, pocket) = splitReleasePocket(release) (release, pocket) = splitReleasePocket(release)
except PocketDoesNotExistError, e: except PocketDoesNotExistError, e:
print 'E: %s' % e Logger.error(e)
sys.exit(1) sys.exit(1)
try: try:
spph = Distribution('ubuntu').getArchive().getSourcePackage(package, release, pocket) spph = Distribution('ubuntu').getArchive().getSourcePackage(package,
release,
pocket)
except (SeriesNotFoundException, PackageNotFoundException), e: except (SeriesNotFoundException, PackageNotFoundException), e:
print 'E: %s' % e Logger.error(e)
sys.exit(1) sys.exit(1)
if options.ubuntu_mirror: if options.ubuntu_mirror:
@ -95,11 +98,14 @@ if __name__ == '__main__':
dsc_url = [url for url in spph.sourceFileUrls() if url.endswith('.dsc')] dsc_url = [url for url in spph.sourceFileUrls() if url.endswith('.dsc')]
assert dsc_url, 'No .dsc file found' assert dsc_url, 'No .dsc file found'
# All good - start downloading... Logger.normal('Fetching the source for %s from %s (%s)...',
print 'Fetching the source for %s from %s (%s)...' % ( package, release.capitalize(), pocket)
package, release.capitalize(), pocket) cmd = ('dget', '-xu', urllib.unquote(dsc_url[0]))
if subprocess.call(['/usr/bin/dget', '-xu', urllib.unquote(dsc_url[0])]) == 0: Logger.command(cmd)
print 'Success!' r = subprocess.call(cmd)
if r == 0:
Logger.normal('Success!')
else: else:
print 'Failed to fetch and extrace the source.', \ Logger.error('Failed to fetch and extrace the source. '
'Please check the output for the error.' 'Please check the output for the error.')
sys.exit(1)