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