mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
sponsor-patch: Make pylint a little bit happier.
This commit is contained in:
parent
8351e6876d
commit
2a2cd83b74
@ -31,7 +31,7 @@ import launchpadlib.launchpad
|
|||||||
import lsb_release
|
import lsb_release
|
||||||
|
|
||||||
from ubuntutools.config import UDTConfig, ubu_email
|
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.logger import Logger
|
||||||
from ubuntutools.question import YesNoQuestion
|
from ubuntutools.question import YesNoQuestion
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ def get_backport_dist(upload, release):
|
|||||||
return release
|
return release
|
||||||
|
|
||||||
def do_build(workdir, package, release, bp_version, builder, update):
|
def do_build(workdir, package, release, bp_version, builder, update):
|
||||||
builder = getBuilder(builder)
|
builder = get_builder(builder)
|
||||||
if not builder:
|
if not builder:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.builder import getBuilder
|
from ubuntutools.builder import get_builder
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools.sponsor_patch.main import main
|
from ubuntutools.sponsor_patch.main import main
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ if not options.update:
|
|||||||
if options.workdir is None:
|
if options.workdir is None:
|
||||||
options.workdir = config.get_value("WORKDIR")
|
options.workdir = config.get_value("WORKDIR")
|
||||||
|
|
||||||
builder = getBuilder(options.builder)
|
builder = get_builder(options.builder)
|
||||||
if not builder:
|
if not builder:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ import subprocess
|
|||||||
|
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
|
|
||||||
|
def build_preparation(result_directory):
|
||||||
|
if not os.path.isdir(result_directory):
|
||||||
|
os.makedirs(result_directory)
|
||||||
|
|
||||||
class Builder(object):
|
class Builder(object):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -31,10 +35,6 @@ class Builder(object):
|
|||||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
self.architecture = process.communicate()[0].strip()
|
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):
|
def build_failure(self, returncode, dsc_file):
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
Logger.error("Failed to build %s from source with %s." % \
|
Logger.error("Failed to build %s from source with %s." % \
|
||||||
@ -59,7 +59,7 @@ class Pbuilder(Builder):
|
|||||||
Builder.__init__(self, "pbuilder")
|
Builder.__init__(self, "pbuilder")
|
||||||
|
|
||||||
def build(self, dsc_file, dist, result_directory):
|
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.
|
# TODO: Do not rely on a specific pbuilder configuration.
|
||||||
cmd = ["sudo", "-E", "DIST=" + dist, "pbuilder", "--build",
|
cmd = ["sudo", "-E", "DIST=" + dist, "pbuilder", "--build",
|
||||||
"--distribution", dist, "--architecture", self.architecture,
|
"--distribution", dist, "--architecture", self.architecture,
|
||||||
@ -81,7 +81,7 @@ class Pbuilderdist(Builder):
|
|||||||
Builder.__init__(self, "pbuilder-dist")
|
Builder.__init__(self, "pbuilder-dist")
|
||||||
|
|
||||||
def build(self, dsc_file, dist, result_directory):
|
def build(self, dsc_file, dist, result_directory):
|
||||||
self.build_preparation(result_directory)
|
build_preparation(result_directory)
|
||||||
cmd = ["pbuilder-dist", dist, self.architecture,
|
cmd = ["pbuilder-dist", dist, self.architecture,
|
||||||
"build", dsc_file, "--buildresult", result_directory]
|
"build", dsc_file, "--buildresult", result_directory]
|
||||||
Logger.command(cmd)
|
Logger.command(cmd)
|
||||||
@ -100,7 +100,7 @@ class Sbuild(Builder):
|
|||||||
Builder.__init__(self, "sbuild")
|
Builder.__init__(self, "sbuild")
|
||||||
|
|
||||||
def build(self, dsc_file, dist, result_directory):
|
def build(self, dsc_file, dist, result_directory):
|
||||||
self.build_preparation(result_directory)
|
build_preparation(result_directory)
|
||||||
workdir = os.getcwd()
|
workdir = os.getcwd()
|
||||||
Logger.command(["cd", result_directory])
|
Logger.command(["cd", result_directory])
|
||||||
os.chdir(result_directory)
|
os.chdir(result_directory)
|
||||||
@ -115,11 +115,10 @@ class Sbuild(Builder):
|
|||||||
def update(self, dist):
|
def update(self, dist):
|
||||||
cmd = ["schroot", "--list"]
|
cmd = ["schroot", "--list"]
|
||||||
Logger.command(cmd)
|
Logger.command(cmd)
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
chroots, _ = p.communicate()
|
chroots, _ = process.communicate()[0].strip().split()
|
||||||
chroots = chroots.strip().split()
|
if process.returncode != 0:
|
||||||
if p.returncode != 0:
|
return process.returncode
|
||||||
return p.returncode
|
|
||||||
|
|
||||||
params = {"dist": dist,
|
params = {"dist": dist,
|
||||||
"arch": self.architecture}
|
"arch": self.architecture}
|
||||||
@ -144,7 +143,7 @@ class Sbuild(Builder):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def getBuilder(builder):
|
def get_builder(builder):
|
||||||
if builder == 'pbuilder':
|
if builder == 'pbuilder':
|
||||||
return Pbuilder()
|
return Pbuilder()
|
||||||
elif builder == 'pbuilder-dist':
|
elif builder == 'pbuilder-dist':
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
class Question(object):
|
class Question(object):
|
||||||
def __init__(self, options, show_help=True):
|
def __init__(self, options, show_help=True):
|
||||||
assert len(options) >= 2
|
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
|
self.show_help = show_help
|
||||||
|
|
||||||
def get_options(self):
|
def get_options(self):
|
||||||
|
@ -71,7 +71,7 @@ def get_fixed_lauchpad_bugs(changes_file):
|
|||||||
fixed_bugs = []
|
fixed_bugs = []
|
||||||
if "Launchpad-Bugs-Fixed" in changes:
|
if "Launchpad-Bugs-Fixed" in changes:
|
||||||
fixed_bugs = changes["Launchpad-Bugs-Fixed"].split(" ")
|
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
|
return fixed_bugs
|
||||||
|
|
||||||
def strip_epoch(version):
|
def strip_epoch(version):
|
||||||
@ -98,7 +98,7 @@ def get_patch_or_branch(bug):
|
|||||||
patch = None
|
patch = None
|
||||||
branch = None
|
branch = None
|
||||||
attached_patches = filter(lambda a: a.type == "Patch", bug.attachments)
|
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(attached_patches) == 0 and len(linked_branches) == 0:
|
||||||
if len(bug.attachments) == 0:
|
if len(bug.attachments) == 0:
|
||||||
Logger.error(("No attachment and no linked branch found on "
|
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])
|
Logger.command(["cd", workdir])
|
||||||
os.chdir(workdir)
|
os.chdir(workdir)
|
||||||
|
|
||||||
lp = launchpadlib.launchpad.Launchpad.login_anonymously("sponsor-patch",
|
launchpad = launchpadlib.launchpad.Launchpad.login_anonymously(
|
||||||
lpinstance)
|
"sponsor-patch", lpinstance)
|
||||||
bug = lp.bugs[bug_number]
|
bug = launchpad.bugs[bug_number]
|
||||||
|
|
||||||
(patch, branch) = get_patch_or_branch(bug)
|
(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)
|
ubuntu_tasks = filter(lambda x: x.is_ubuntu_task(), bug_tasks)
|
||||||
if len(ubuntu_tasks) == 0:
|
if len(ubuntu_tasks) == 0:
|
||||||
Logger.error("No Ubuntu bug task found on bug #%i." % (bug_number))
|
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()
|
ask_for_manual_fixing()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ubuntu = lp.distributions['ubuntu']
|
ubuntu = launchpad.distributions['ubuntu']
|
||||||
devel_series = ubuntu.current_series.name
|
devel_series = ubuntu.current_series.name
|
||||||
supported_series = [series.name for series in ubuntu.series
|
supported_series = [series.name for series in ubuntu.series
|
||||||
if series.active and series.name != devel_series]
|
if series.active and series.name != devel_series]
|
||||||
# Make sure that the target is correct
|
# Make sure that the target is correct
|
||||||
if upload == "ubuntu":
|
if upload == "ubuntu":
|
||||||
allowed = map(lambda s: s + "-proposed", supported_series) + \
|
allowed = [s + "-proposed" for s in supported_series] + \
|
||||||
[devel_series]
|
[devel_series]
|
||||||
if changelog.distributions not in allowed:
|
if changelog.distributions not in allowed:
|
||||||
Logger.error(("%s is not an allowed series. It needs to be one "
|
Logger.error(("%s is not an allowed series. It needs to be one "
|
||||||
|
@ -27,8 +27,7 @@ class Patch(object):
|
|||||||
cmd = ["diffstat", "-l", "-p0", self.full_path]
|
cmd = ["diffstat", "-l", "-p0", self.full_path]
|
||||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
changed_files = process.communicate()[0]
|
changed_files = process.communicate()[0]
|
||||||
self.changed_files = filter(lambda l: l != "",
|
self.changed_files = [l for l in changed_files.split("\n") if l != ""]
|
||||||
changed_files.split("\n"))
|
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self.patch_file
|
return self.patch_file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user