pull-lp-source: Make pylint a little bit happier.

This commit is contained in:
Benjamin Drung 2010-12-25 16:32:29 +01:00
parent 9f340a7562
commit 8ebee7e0f2

View File

@ -34,31 +34,30 @@ from ubuntutools.logger import Logger
from ubuntutools.lp.lpapicache import Distribution, Launchpad from ubuntutools.lp.lpapicache import Distribution, Launchpad
from ubuntutools.lp.udtexceptions import (SeriesNotFoundException, from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
PackageNotFoundException, PocketDoesNotExistError) PackageNotFoundException, PocketDoesNotExistError)
from ubuntutools.misc import splitReleasePocket, dsc_name, dsc_url from ubuntutools.misc import splitReleasePocket, dsc_url
if not os.path.exists("/usr/bin/dget"): if not os.path.exists("/usr/bin/dget"):
print ("E: dget is not installed - please install the 'devscripts' package" print ("E: dget is not installed - please install the 'devscripts' package"
" and rerun this script again.") " and rerun this script again.")
sys.exit(1) sys.exit(1)
if __name__ == '__main__': def main():
usage = "Usage: %prog <package> [release]" usage = "Usage: %prog <package> [release]"
optParser = OptionParser(usage) opt_parser = OptionParser(usage)
optParser.add_option('-d', '--download-only', opt_parser.add_option('-d', '--download-only',
dest='download_only', default=False, dest='download_only', default=False,
action='store_true', action='store_true',
help="Do not extract the source package") help="Do not extract the source package")
optParser.add_option('-m', '--mirror', metavar='UBUNTU_MIRROR', opt_parser.add_option('-m', '--mirror', metavar='UBUNTU_MIRROR',
dest='ubuntu_mirror', dest='ubuntu_mirror',
help='Preferred Ubuntu mirror ' help='Preferred Ubuntu mirror (default: Launchpad)')
'(default: Launchpad)') opt_parser.add_option('--no-conf',
optParser.add_option('--no-conf', dest='no_conf', default=False, action='store_true',
dest='no_conf', default=False, action='store_true', help="Don't read config files or environment "
help="Don't read config files or environment " "variables")
"variables") (options, args) = opt_parser.parse_args()
(options, args) = optParser.parse_args()
if not args: if not args:
optParser.error("Must specify package name") opt_parser.error("Must specify package name")
config = UDTConfig(options.no_conf) config = UDTConfig(options.no_conf)
if options.ubuntu_mirror is None: if options.ubuntu_mirror is None:
@ -77,16 +76,16 @@ if __name__ == '__main__':
try: try:
(release, pocket) = splitReleasePocket(release) (release, pocket) = splitReleasePocket(release)
except PocketDoesNotExistError, e: except PocketDoesNotExistError, error:
Logger.error(e) Logger.error(error)
sys.exit(1) sys.exit(1)
try: try:
spph = Distribution('ubuntu').getArchive().getSourcePackage(package, spph = Distribution('ubuntu').getArchive().getSourcePackage(package,
release, release,
pocket) pocket)
except (SeriesNotFoundException, PackageNotFoundException), e: except (SeriesNotFoundException, PackageNotFoundException), error:
Logger.error(e) Logger.error(error)
sys.exit(1) sys.exit(1)
urls = [] urls = []
@ -102,11 +101,14 @@ if __name__ == '__main__':
for url in urls: for url in urls:
cmd = ('dget', '-u' + ('d' if options.download_only else 'x'), url) cmd = ('dget', '-u' + ('d' if options.download_only else 'x'), url)
Logger.command(cmd) Logger.command(cmd)
r = subprocess.call(cmd) return_code = subprocess.call(cmd)
if r == 0: if return_code == 0:
Logger.normal("Success!") Logger.normal("Success!")
sys.exit(0) sys.exit(0)
Logger.error('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) sys.exit(1)
if __name__ == '__main__':
main()