mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 15:41:09 +00:00
Pyflakes & PEP-8 fine-tooth comb applied
This commit is contained in:
parent
857778b922
commit
1f2d2e8d62
60
syncpackage
60
syncpackage
@ -37,8 +37,8 @@ from lazr.restfulclient.errors import HTTPError
|
||||
from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage,
|
||||
DownloadError)
|
||||
from ubuntutools.config import UDTConfig, ubu_email
|
||||
from ubuntutools.requestsync.mail import (get_debian_srcpkg
|
||||
as requestsync_mail_get_debian_srcpkg)
|
||||
from ubuntutools.requestsync.mail import (
|
||||
get_debian_srcpkg as requestsync_mail_get_debian_srcpkg)
|
||||
from ubuntutools.requestsync.lp import get_debian_srcpkg, get_ubuntu_srcpkg
|
||||
from ubuntutools.lp import udtexceptions
|
||||
from ubuntutools.lp.lpapicache import (Distribution, Launchpad,
|
||||
@ -52,9 +52,9 @@ class Version(debian.debian_support.Version):
|
||||
def strip_epoch(self):
|
||||
'''Removes the epoch from a Debian version string.
|
||||
|
||||
strip_epoch(1:1.52-1) will return "1.52-1" and strip_epoch(1.1.3-1) will
|
||||
return "1.1.3-1".'''
|
||||
|
||||
strip_epoch(1:1.52-1) will return "1.52-1" and strip_epoch(1.1.3-1)
|
||||
will return "1.1.3-1".
|
||||
'''
|
||||
parts = self.full_version.split(':')
|
||||
if len(parts) > 1:
|
||||
del parts[0]
|
||||
@ -62,6 +62,7 @@ class Version(debian.debian_support.Version):
|
||||
return version_without_epoch
|
||||
|
||||
def get_related_debian_version(self):
|
||||
'''Strip the ubuntu-specific bits off the version'''
|
||||
related_debian_version = self.full_version
|
||||
uidx = related_debian_version.find('ubuntu')
|
||||
if uidx > 0:
|
||||
@ -72,6 +73,7 @@ class Version(debian.debian_support.Version):
|
||||
return Version(related_debian_version)
|
||||
|
||||
def is_modified_in_ubuntu(self):
|
||||
'''Did Ubuntu modify this (and mark the version appropriately?'''
|
||||
return 'ubuntu' in self.full_version
|
||||
|
||||
|
||||
@ -97,6 +99,7 @@ def remove_signature(dscname):
|
||||
dsc_file.writelines(unsigned_file)
|
||||
dsc_file.close()
|
||||
|
||||
|
||||
def add_fixed_bugs(changes, bugs):
|
||||
'''Add additional Launchpad bugs to the list of fixed bugs in changes
|
||||
file.'''
|
||||
@ -117,15 +120,22 @@ def add_fixed_bugs(changes, bugs):
|
||||
|
||||
return "\n".join(changes + [""])
|
||||
|
||||
|
||||
def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
||||
keyid=None, simulate=False, force=False, fakesync=False):
|
||||
'''Local sync, trying to emulate sync-source.py
|
||||
Grabs a source package, replaces the .orig.tar with the one from Ubuntu,
|
||||
if necessary, writes a sync-appropriate .changes file, and signs it.
|
||||
'''
|
||||
|
||||
uploader = name + " <" + email + ">"
|
||||
|
||||
src_pkg.pull_dsc()
|
||||
new_ver = Version(src_pkg.dsc["Version"])
|
||||
|
||||
try:
|
||||
ubuntu_source = get_ubuntu_srcpkg(src_pkg.source, release.split("-")[0])
|
||||
ubuntu_source = get_ubuntu_srcpkg(src_pkg.source,
|
||||
release.split("-")[0])
|
||||
ubuntu_ver = Version(ubuntu_source.getVersion())
|
||||
ubu_pkg = UbuntuSourcePackage(src_pkg.source, ubuntu_ver.full_version,
|
||||
ubuntu_source.getComponent(),
|
||||
@ -206,7 +216,8 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
||||
if not Logger.verbose:
|
||||
cmd += ["-q"]
|
||||
Logger.command(cmd + ['>', '../' + changes_filename])
|
||||
changes = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
|
||||
changes = subprocess.Popen(cmd, stdout=subprocess.PIPE) \
|
||||
.communicate()[0]
|
||||
|
||||
# Add additional bug numbers
|
||||
if len(bugs) > 0:
|
||||
@ -266,7 +277,9 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
||||
'Please check build log above.')
|
||||
sys.exit(1)
|
||||
|
||||
def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
|
||||
|
||||
def fetch_source_pkg(package, dist, version, component, ubuntu_release,
|
||||
mirror):
|
||||
"""Download the specified source package.
|
||||
dist, version, component, mirror can all be None.
|
||||
"""
|
||||
@ -320,6 +333,7 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
|
||||
return DebianSourcePackage(package, version.full_version, component,
|
||||
mirrors=mirrors)
|
||||
|
||||
|
||||
def copy(src_pkg, release, bugs, simulate=False, force=False):
|
||||
"""Copy a source package from Debian to Ubuntu using the Launchpad API."""
|
||||
ubuntu = Distribution('ubuntu')
|
||||
@ -413,6 +427,7 @@ def copy(src_pkg, release, bugs, simulate=False, force=False):
|
||||
close_bugs(bugs, src_pkg.source, src_pkg.version.full_version,
|
||||
changes)
|
||||
|
||||
|
||||
def is_blacklisted(query):
|
||||
""""Determine if package "query" is in the sync blacklist
|
||||
Returns tuple of (blacklisted, comments)
|
||||
@ -422,8 +437,8 @@ def is_blacklisted(query):
|
||||
lp_comments = series.getDifferenceComments(source_package_name=query)
|
||||
blacklisted = False
|
||||
comments = [u'%s\n -- %s %s'
|
||||
%(c.body_text, c.comment_author.name,
|
||||
c.comment_date.strftime('%a, %d %b %Y %H:%M:%S +0000'))
|
||||
% (c.body_text, c.comment_author.name,
|
||||
c.comment_date.strftime('%a, %d %b %Y %H:%M:%S +0000'))
|
||||
for c in lp_comments]
|
||||
|
||||
for diff in series.getDifferencesTo(source_package_name_filter=query):
|
||||
@ -451,6 +466,7 @@ def is_blacklisted(query):
|
||||
|
||||
return (blacklisted, comments)
|
||||
|
||||
|
||||
def close_bugs(bugs, package, version, changes):
|
||||
"""Close the correct task on all bugs, with changes"""
|
||||
ubuntu = Launchpad.distributions['ubuntu']
|
||||
@ -475,6 +491,7 @@ def close_bugs(bugs, package, version, changes):
|
||||
else:
|
||||
Logger.error(u"Cannot find any tasks on LP: #%i to close.", bug.id)
|
||||
|
||||
|
||||
def parse():
|
||||
"""Parse given command-line parameters."""
|
||||
|
||||
@ -499,8 +516,8 @@ def parse():
|
||||
help="Display more progress information.")
|
||||
parser.add_option("-F", "--fakesync",
|
||||
action="store_true", default=False,
|
||||
help="Perform a fakesync (a sync where Debian and Ubuntu "
|
||||
"have a .orig.tar mismatch).")
|
||||
help="Perform a fakesync (a sync where Debian and "
|
||||
"Ubuntu have a .orig.tar mismatch).")
|
||||
parser.add_option("-f", "--force",
|
||||
action="store_true", default=False,
|
||||
help="Force sync over the top of Ubuntu changes.")
|
||||
@ -582,6 +599,7 @@ def parse():
|
||||
|
||||
|
||||
def main():
|
||||
'''Handle parameters and get the ball rolling'''
|
||||
(options, package) = parse()
|
||||
|
||||
Logger.verbose = options.verbose
|
||||
@ -609,7 +627,8 @@ def main():
|
||||
|
||||
src_pkg = fetch_source_pkg(package, options.distribution,
|
||||
options.debian_version,
|
||||
options.component, options.release.split("-")[0],
|
||||
options.component,
|
||||
options.release.split("-")[0],
|
||||
options.debian_mirror)
|
||||
|
||||
blacklisted, comments = is_blacklisted(src_pkg.source)
|
||||
@ -619,14 +638,16 @@ def main():
|
||||
|
||||
if blacklisted == 'CURRENT':
|
||||
Logger.debug("Source package %s is temporarily blacklisted "
|
||||
"(blacklisted_current). Ubuntu ignores these for now. "
|
||||
"(blacklisted_current). "
|
||||
"Ubuntu ignores these for now. "
|
||||
"See also LP: #841372", src_pkg.source)
|
||||
else:
|
||||
if options.fakesync:
|
||||
messages += ["Doing a fakesync, overriding blacklist."]
|
||||
else:
|
||||
blacklist_fail = True
|
||||
messages += ["If this package needs a fakesync, use --fakesync",
|
||||
messages += ["If this package needs a fakesync, "
|
||||
"use --fakesync",
|
||||
"If you think this package shouldn't be "
|
||||
"blacklisted, please file a bug explaining your "
|
||||
"reasoning and subscribe ~ubuntu-archive."]
|
||||
@ -654,10 +675,11 @@ def main():
|
||||
options.force)
|
||||
else:
|
||||
os.environ['DEB_VENDOR'] = 'Ubuntu'
|
||||
sync_dsc(src_pkg, options.distribution, options.release, options.uploader_name,
|
||||
options.uploader_email, options.bugs, options.ubuntu_mirror,
|
||||
options.keyid, options.simulate, options.force,
|
||||
options.fakesync)
|
||||
sync_dsc(src_pkg, options.distribution, options.release,
|
||||
options.uploader_name, options.uploader_email, options.bugs,
|
||||
options.ubuntu_mirror, options.keyid, options.simulate,
|
||||
options.force, options.fakesync)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user