mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
ubuntu-build: Make pylint happier.
This commit is contained in:
parent
c19ff094b1
commit
53c5d801f8
101
ubuntu-build
101
ubuntu-build
@ -32,6 +32,7 @@ from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
|
|||||||
from ubuntutools.lp.lpapicache import Distribution, PersonTeam
|
from ubuntutools.lp.lpapicache import Distribution, PersonTeam
|
||||||
from ubuntutools.misc import splitReleasePocket
|
from ubuntutools.misc import splitReleasePocket
|
||||||
|
|
||||||
|
def main():
|
||||||
# Usage.
|
# Usage.
|
||||||
usage = "%prog <srcpackage> <release> <operation>\n\n"
|
usage = "%prog <srcpackage> <release> <operation>\n\n"
|
||||||
usage += "Where operation may be one of: rescore, retry, or status.\n"
|
usage += "Where operation may be one of: rescore, retry, or status.\n"
|
||||||
@ -42,21 +43,24 @@ valid_archs = set(["armel", "amd64", "hppa", "i386",
|
|||||||
"ia64", "lpia", "powerpc", "sparc"])
|
"ia64", "lpia", "powerpc", "sparc"])
|
||||||
|
|
||||||
# Prepare our option parser.
|
# Prepare our option parser.
|
||||||
optParser = OptionParser(usage)
|
opt_parser = OptionParser(usage)
|
||||||
|
|
||||||
# Retry options
|
# Retry options
|
||||||
retryRescoreOptions = OptionGroup(optParser, "Retry and rescore options",
|
retry_rescore_options = OptionGroup(opt_parser, "Retry and rescore options",
|
||||||
"These options may only be used with the 'retry' and 'rescore' operations.")
|
"These options may only be used with "
|
||||||
retryRescoreOptions.add_option("-a", "--arch", type = "string",
|
"the 'retry' and 'rescore' operations.")
|
||||||
|
retry_rescore_options.add_option("-a", "--arch", type="string",
|
||||||
action="append", dest="architecture",
|
action="append", dest="architecture",
|
||||||
help = "Rebuild or rescore a specific architecture. " \
|
help="Rebuild or rescore a specific "
|
||||||
"Valid architectures include: " \
|
"architecture. Valid architectures "
|
||||||
"%s." % ", ".join(valid_archs))
|
"include: %s." %
|
||||||
|
", ".join(valid_archs))
|
||||||
|
|
||||||
# Batch processing options
|
# Batch processing options
|
||||||
batch_options = OptionGroup(optParser, "Batch processing",
|
batch_options = OptionGroup(opt_parser, "Batch processing",
|
||||||
"These options and parameter ordering is only available in --batch mode.\n"
|
"These options and parameter ordering is only "
|
||||||
"Usage: ubuntu-build --batch [options] <package>...")
|
"available in --batch mode.\nUsage: "
|
||||||
|
"ubuntu-build --batch [options] <package>...")
|
||||||
batch_options.add_option('--batch',
|
batch_options.add_option('--batch',
|
||||||
action='store_true', dest='batch', default=False,
|
action='store_true', dest='batch', default=False,
|
||||||
help='Enable batch mode')
|
help='Enable batch mode')
|
||||||
@ -70,36 +74,35 @@ batch_options.add_option('--retry',
|
|||||||
batch_options.add_option('--rescore',
|
batch_options.add_option('--rescore',
|
||||||
action='store', dest='priority', type='int',
|
action='store', dest='priority', type='int',
|
||||||
help='Rescore builds to <priority>.')
|
help='Rescore builds to <priority>.')
|
||||||
batch_options.add_option('--arch2',
|
batch_options.add_option('--arch2', action='append', dest='architecture',
|
||||||
action='append', dest='architecture', type='string',
|
type='string',
|
||||||
help="Affect only 'architecture' "
|
help="Affect only 'architecture' (can be used "
|
||||||
"(can be used several times). "
|
"several times). Valid architectures are: %s."
|
||||||
"Valid architectures are: %s."
|
|
||||||
% ', '.join(valid_archs))
|
% ', '.join(valid_archs))
|
||||||
|
|
||||||
# Add the retry options to the main group.
|
# Add the retry options to the main group.
|
||||||
optParser.add_option_group(retryRescoreOptions)
|
opt_parser.add_option_group(retry_rescore_options)
|
||||||
# Add the batch mode to the main group.
|
# Add the batch mode to the main group.
|
||||||
optParser.add_option_group(batch_options)
|
opt_parser.add_option_group(batch_options)
|
||||||
|
|
||||||
# Parse our options.
|
# Parse our options.
|
||||||
(options, args) = optParser.parse_args()
|
(options, args) = opt_parser.parse_args()
|
||||||
|
|
||||||
if not len(args):
|
if not len(args):
|
||||||
optParser.print_help()
|
opt_parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not options.batch:
|
if not options.batch:
|
||||||
# Check we have the correct number of arguments.
|
# Check we have the correct number of arguments.
|
||||||
if len(args) < 3:
|
if len(args) < 3:
|
||||||
optParser.error("Incorrect number of arguments.")
|
opt_parser.error("Incorrect number of arguments.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
package = str(args[0]).lower()
|
package = str(args[0]).lower()
|
||||||
release = str(args[1]).lower()
|
release = str(args[1]).lower()
|
||||||
op = str(args[2]).lower()
|
op = str(args[2]).lower()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
optParser.print_help()
|
opt_parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Check our operation.
|
# Check our operation.
|
||||||
@ -115,15 +118,15 @@ if not options.batch:
|
|||||||
% options.architecture[0])
|
% options.architecture[0])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
oneArch = True
|
one_arch = True
|
||||||
else:
|
else:
|
||||||
oneArch = False
|
one_arch = False
|
||||||
|
|
||||||
# split release and pocket
|
# split release and pocket
|
||||||
try:
|
try:
|
||||||
(release, pocket) = splitReleasePocket(release)
|
(release, pocket) = splitReleasePocket(release)
|
||||||
except PocketDoesNotExistError, e:
|
except PocketDoesNotExistError, error:
|
||||||
print 'E: %s' % e
|
print 'E: %s' % error
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Get the ubuntu archive
|
# Get the ubuntu archive
|
||||||
@ -136,8 +139,8 @@ if not options.batch:
|
|||||||
try:
|
try:
|
||||||
sources = ubuntu_archive.getSourcePackage(package, release, pocket)
|
sources = ubuntu_archive.getSourcePackage(package, release, pocket)
|
||||||
distroseries = Distribution('ubuntu').getSeries(release)
|
distroseries = Distribution('ubuntu').getSeries(release)
|
||||||
except (SeriesNotFoundException, PackageNotFoundException), e:
|
except (SeriesNotFoundException, PackageNotFoundException), error:
|
||||||
print e
|
print error
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
# Get list of builds for that package.
|
# Get list of builds for that package.
|
||||||
builds = sources.getBuilds()
|
builds = sources.getBuilds()
|
||||||
@ -147,20 +150,20 @@ if not options.batch:
|
|||||||
component = sources.getComponent()
|
component = sources.getComponent()
|
||||||
|
|
||||||
# Operations that are remaining may only be done by Ubuntu developers
|
# Operations that are remaining may only be done by Ubuntu developers
|
||||||
# (retry) or buildd admins (rescore). Check if the proper permissions are
|
# (retry) or buildd admins (rescore). Check if the proper permissions
|
||||||
# in place.
|
# are in place.
|
||||||
me = PersonTeam.me
|
me = PersonTeam.me
|
||||||
if op == "rescore":
|
if op == "rescore":
|
||||||
necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins')
|
necessary_privs = me.isLpTeamMember('launchpad-buildd-admins')
|
||||||
if op == "retry":
|
if op == "retry":
|
||||||
necessaryPrivs = me.canUploadPackage(ubuntu_archive, distroseries,
|
necessary_privs = me.canUploadPackage(ubuntu_archive, distroseries,
|
||||||
sources.getPackageName(),
|
sources.getPackageName(),
|
||||||
sources.getComponent())
|
sources.getComponent())
|
||||||
|
|
||||||
if op in ('rescore', 'retry') and not necessaryPrivs:
|
if op in ('rescore', 'retry') and not necessary_privs:
|
||||||
print >> sys.stderr, ("You cannot perform the %s operation on a %s "
|
print >> sys.stderr, ("You cannot perform the %s operation on a %s "
|
||||||
"package as you do not have the permissions to "
|
"package as you do not have the permissions "
|
||||||
"do this action." % (op, component))
|
"to do this action." % (op, component))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Output details.
|
# Output details.
|
||||||
@ -172,7 +175,7 @@ if not options.batch:
|
|||||||
# Output list of arches for package and their status.
|
# Output list of arches for package and their status.
|
||||||
done = False
|
done = False
|
||||||
for build in builds:
|
for build in builds:
|
||||||
if oneArch and build.arch_tag != options.architecture[0]:
|
if one_arch and build.arch_tag != options.architecture[0]:
|
||||||
# Skip this architecture.
|
# Skip this architecture.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -182,7 +185,8 @@ if not options.batch:
|
|||||||
if build.can_be_rescored:
|
if build.can_be_rescored:
|
||||||
# FIXME: make priority an option
|
# FIXME: make priority an option
|
||||||
priority = 5000
|
priority = 5000
|
||||||
print 'Rescoring build %s to %d...' % (build.arch_tag, priority)
|
print 'Rescoring build %s to %d...' % \
|
||||||
|
(build.arch_tag, priority)
|
||||||
build.rescore(score = priority)
|
build.rescore(score = priority)
|
||||||
else:
|
else:
|
||||||
print 'Cannot rescore build on %s.' % build.arch_tag
|
print 'Cannot rescore build on %s.' % build.arch_tag
|
||||||
@ -195,7 +199,8 @@ if not options.batch:
|
|||||||
|
|
||||||
|
|
||||||
# We are done
|
# We are done
|
||||||
if done: sys.exit(0)
|
if done:
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
print ("No builds for '%s' found in the %s release - it may have been "
|
print ("No builds for '%s' found in the %s release - it may have been "
|
||||||
"built in a former release." % (package, release.capitalize()))
|
"built in a former release." % (package, release.capitalize()))
|
||||||
@ -212,18 +217,19 @@ else:
|
|||||||
# filter out duplicate and invalid architectures
|
# filter out duplicate and invalid architectures
|
||||||
archs.intersection_update(valid_archs)
|
archs.intersection_update(valid_archs)
|
||||||
|
|
||||||
release = options.series or Distribution('ubuntu').getDevelopmentSeries().name
|
release = (options.series or
|
||||||
|
Distribution('ubuntu').getDevelopmentSeries().name)
|
||||||
try:
|
try:
|
||||||
(release, pocket) = splitReleasePocket(release)
|
(release, pocket) = splitReleasePocket(release)
|
||||||
except PocketDoesNotExistError, e:
|
except PocketDoesNotExistError, error:
|
||||||
print 'E: %s' % e
|
print 'E: %s' % error
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
ubuntu_archive = Distribution('ubuntu').getArchive()
|
ubuntu_archive = Distribution('ubuntu').getArchive()
|
||||||
try:
|
try:
|
||||||
distroseries = Distribution('ubuntu').getSeries(release)
|
distroseries = Distribution('ubuntu').getSeries(release)
|
||||||
except SeriesNotFoundException, e:
|
except SeriesNotFoundException, error:
|
||||||
print e
|
print error
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
me = PersonTeam.me
|
me = PersonTeam.me
|
||||||
|
|
||||||
@ -232,14 +238,14 @@ can_rescore = ((options.priority
|
|||||||
and me.isLpTeamMember('launchpad-buildd-admins'))
|
and me.isLpTeamMember('launchpad-buildd-admins'))
|
||||||
or False)
|
or False)
|
||||||
if options.priority and not can_rescore:
|
if options.priority and not can_rescore:
|
||||||
print >> sys.stderr, ("You don't have the permissions to rescore builds. "
|
print >> sys.stderr, ("You don't have the permissions to rescore "
|
||||||
"Ignoring your rescore request.")
|
"builds. Ignoring your rescore request.")
|
||||||
|
|
||||||
for pkg in args:
|
for pkg in args:
|
||||||
try:
|
try:
|
||||||
pkg = ubuntu_archive.getSourcePackage(pkg, release, pocket)
|
pkg = ubuntu_archive.getSourcePackage(pkg, release, pocket)
|
||||||
except PackageNotFoundException, e:
|
except PackageNotFoundException, error:
|
||||||
print e
|
print error
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check permissions (part 2): check upload permissions for the source
|
# Check permissions (part 2): check upload permissions for the source
|
||||||
@ -263,3 +269,6 @@ for pkg in args:
|
|||||||
print pkg.rescoreBuilds(archs, options.priority)
|
print pkg.rescoreBuilds(archs, options.priority)
|
||||||
|
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user