sponsor-patch: Make pylint a little bit happier.

This commit is contained in:
Benjamin Drung 2010-12-22 23:31:35 +01:00
parent 8351e6876d
commit 2a2cd83b74
6 changed files with 26 additions and 28 deletions

View File

@ -31,7 +31,7 @@ import launchpadlib.launchpad
import lsb_release
from ubuntutools.config import UDTConfig, ubu_email
from ubuntutools.builder import getBuilder
from ubuntutools.builder import get_builder
from ubuntutools.logger import Logger
from ubuntutools.question import YesNoQuestion
@ -214,7 +214,7 @@ def get_backport_dist(upload, release):
return release
def do_build(workdir, package, release, bp_version, builder, update):
builder = getBuilder(builder)
builder = get_builder(builder)
if not builder:
return

View File

@ -21,7 +21,7 @@ import sys
import tempfile
from ubuntutools.config import UDTConfig
from ubuntutools.builder import getBuilder
from ubuntutools.builder import get_builder
from ubuntutools.logger import Logger
from ubuntutools.sponsor_patch.main import main
@ -85,7 +85,7 @@ if not options.update:
if options.workdir is None:
options.workdir = config.get_value("WORKDIR")
builder = getBuilder(options.builder)
builder = get_builder(options.builder)
if not builder:
sys.exit(1)

View File

@ -24,6 +24,10 @@ import subprocess
from ubuntutools.logger import Logger
def build_preparation(result_directory):
if not os.path.isdir(result_directory):
os.makedirs(result_directory)
class Builder(object):
def __init__(self, name):
self.name = name
@ -31,10 +35,6 @@ class Builder(object):
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
self.architecture = process.communicate()[0].strip()
def build_preparation(self, result_directory):
if not os.path.isdir(result_directory):
os.makedirs(result_directory)
def build_failure(self, returncode, dsc_file):
if returncode != 0:
Logger.error("Failed to build %s from source with %s." % \
@ -59,7 +59,7 @@ class Pbuilder(Builder):
Builder.__init__(self, "pbuilder")
def build(self, dsc_file, dist, result_directory):
self.build_preparation(result_directory)
build_preparation(result_directory)
# TODO: Do not rely on a specific pbuilder configuration.
cmd = ["sudo", "-E", "DIST=" + dist, "pbuilder", "--build",
"--distribution", dist, "--architecture", self.architecture,
@ -81,7 +81,7 @@ class Pbuilderdist(Builder):
Builder.__init__(self, "pbuilder-dist")
def build(self, dsc_file, dist, result_directory):
self.build_preparation(result_directory)
build_preparation(result_directory)
cmd = ["pbuilder-dist", dist, self.architecture,
"build", dsc_file, "--buildresult", result_directory]
Logger.command(cmd)
@ -100,7 +100,7 @@ class Sbuild(Builder):
Builder.__init__(self, "sbuild")
def build(self, dsc_file, dist, result_directory):
self.build_preparation(result_directory)
build_preparation(result_directory)
workdir = os.getcwd()
Logger.command(["cd", result_directory])
os.chdir(result_directory)
@ -115,11 +115,10 @@ class Sbuild(Builder):
def update(self, dist):
cmd = ["schroot", "--list"]
Logger.command(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
chroots, _ = p.communicate()
chroots = chroots.strip().split()
if p.returncode != 0:
return p.returncode
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
chroots, _ = process.communicate()[0].strip().split()
if process.returncode != 0:
return process.returncode
params = {"dist": dist,
"arch": self.architecture}
@ -144,7 +143,7 @@ class Sbuild(Builder):
return 0
def getBuilder(builder):
def get_builder(builder):
if builder == 'pbuilder':
return Pbuilder()
elif builder == 'pbuilder-dist':

View File

@ -18,7 +18,7 @@
class Question(object):
def __init__(self, options, show_help=True):
assert len(options) >= 2
self.options = map(lambda s: s.lower(), options)
self.options = [s.lower() for s in options]
self.show_help = show_help
def get_options(self):

View File

@ -71,7 +71,7 @@ def get_fixed_lauchpad_bugs(changes_file):
fixed_bugs = []
if "Launchpad-Bugs-Fixed" in changes:
fixed_bugs = changes["Launchpad-Bugs-Fixed"].split(" ")
fixed_bugs = map(int, fixed_bugs)
fixed_bugs = [int(bug) for bug in fixed_bugs]
return fixed_bugs
def strip_epoch(version):
@ -98,7 +98,7 @@ def get_patch_or_branch(bug):
patch = None
branch = None
attached_patches = filter(lambda a: a.type == "Patch", bug.attachments)
linked_branches = map(lambda b: b.branch, bug.linked_branches)
linked_branches = [b.branch for b in bug.linked_branches]
if len(attached_patches) == 0 and len(linked_branches) == 0:
if len(bug.attachments) == 0:
Logger.error(("No attachment and no linked branch found on "
@ -221,13 +221,13 @@ def main(bug_number, build, builder, edit, keyid, lpinstance, update, upload,
Logger.command(["cd", workdir])
os.chdir(workdir)
lp = launchpadlib.launchpad.Launchpad.login_anonymously("sponsor-patch",
lpinstance)
bug = lp.bugs[bug_number]
launchpad = launchpadlib.launchpad.Launchpad.login_anonymously(
"sponsor-patch", lpinstance)
bug = launchpad.bugs[bug_number]
(patch, branch) = get_patch_or_branch(bug)
bug_tasks = map(lambda x: BugTask(x, lp), bug.bug_tasks)
bug_tasks = [BugTask(x, launchpad) for x in bug.bug_tasks]
ubuntu_tasks = filter(lambda x: x.is_ubuntu_task(), bug_tasks)
if len(ubuntu_tasks) == 0:
Logger.error("No Ubuntu bug task found on bug #%i." % (bug_number))
@ -371,13 +371,13 @@ def main(bug_number, build, builder, edit, keyid, lpinstance, update, upload,
ask_for_manual_fixing()
continue
ubuntu = lp.distributions['ubuntu']
ubuntu = launchpad.distributions['ubuntu']
devel_series = ubuntu.current_series.name
supported_series = [series.name for series in ubuntu.series
if series.active and series.name != devel_series]
# Make sure that the target is correct
if upload == "ubuntu":
allowed = map(lambda s: s + "-proposed", supported_series) + \
allowed = [s + "-proposed" for s in supported_series] + \
[devel_series]
if changelog.distributions not in allowed:
Logger.error(("%s is not an allowed series. It needs to be one "

View File

@ -27,8 +27,7 @@ class Patch(object):
cmd = ["diffstat", "-l", "-p0", self.full_path]
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
changed_files = process.communicate()[0]
self.changed_files = filter(lambda l: l != "",
changed_files.split("\n"))
self.changed_files = [l for l in changed_files.split("\n") if l != ""]
def get_name(self):
return self.patch_file