mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-09 16:01:28 +00:00
syncpackage: Make pylint a little bit happier.
This commit is contained in:
parent
2a2cd83b74
commit
b18aa6209a
56
syncpackage
56
syncpackage
@ -31,7 +31,8 @@ import sys
|
|||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
# ubuntu-dev-tools modules
|
# ubuntu-dev-tools modules
|
||||||
from ubuntutools.requestsync.mail import getDebianSrcPkg as requestsync_mail_getDebianSrcPkg
|
from ubuntutools.requestsync.mail import getDebianSrcPkg \
|
||||||
|
as requestsync_mail_getDebianSrcPkg
|
||||||
from ubuntutools.requestsync.lp import getDebianSrcPkg, getUbuntuSrcPkg
|
from ubuntutools.requestsync.lp import getDebianSrcPkg, getUbuntuSrcPkg
|
||||||
from ubuntutools.lp import udtexceptions
|
from ubuntutools.lp import udtexceptions
|
||||||
from ubuntutools.lp.lpapicache import Launchpad
|
from ubuntutools.lp.lpapicache import Launchpad
|
||||||
@ -66,17 +67,17 @@ class File(object):
|
|||||||
|
|
||||||
if file_exists:
|
if file_exists:
|
||||||
# Check for correct checksum
|
# Check for correct checksum
|
||||||
m = hashlib.md5()
|
md5 = hashlib.md5()
|
||||||
m.update(open(self.name).read())
|
md5.update(open(self.name).read())
|
||||||
file_exists = m.hexdigest() == self.checksum
|
file_exists = md5.hexdigest() == self.checksum
|
||||||
|
|
||||||
if not file_exists:
|
if not file_exists:
|
||||||
if verbose:
|
if verbose:
|
||||||
print '%s: I: Downloading %s...' % (script_name, self.url)
|
print '%s: I: Downloading %s...' % (script_name, self.url)
|
||||||
try:
|
try:
|
||||||
urllib.urlretrieve(self.url, self.name)
|
urllib.urlretrieve(self.url, self.name)
|
||||||
except IOError as e:
|
except IOError as err:
|
||||||
parameters = (script_name, self.name, e.errno, e.strerror)
|
parameters = (script_name, self.name, err.errno, err.strerror)
|
||||||
print >> sys.stderr, ("%s: Error: Failed to download %s "
|
print >> sys.stderr, ("%s: Error: Failed to download %s "
|
||||||
"[Errno %i]: %s.") % parameters
|
"[Errno %i]: %s.") % parameters
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -118,22 +119,22 @@ def quote_parameter(parameter):
|
|||||||
def print_command(script_name, cmd):
|
def print_command(script_name, cmd):
|
||||||
print "%s: I: %s" % (script_name, " ".join(map(quote_parameter, cmd)))
|
print "%s: I: %s" % (script_name, " ".join(map(quote_parameter, cmd)))
|
||||||
|
|
||||||
def remove_signature(dscname, script_name=None, verbose=False):
|
def remove_signature(dscname):
|
||||||
'''Removes the signature from a .dsc file if the .dsc file is signed.'''
|
'''Removes the signature from a .dsc file if the .dsc file is signed.'''
|
||||||
|
|
||||||
f = open(dscname)
|
f = open(dscname)
|
||||||
if f.readline().strip() == "-----BEGIN PGP SIGNED MESSAGE-----":
|
if f.readline().strip() == "-----BEGIN PGP SIGNED MESSAGE-----":
|
||||||
unsigned_file = []
|
unsigned_file = []
|
||||||
# search until begin of body found
|
# search until begin of body found
|
||||||
for l in f:
|
for line in f:
|
||||||
if l.strip() == "":
|
if line.strip() == "":
|
||||||
break
|
break
|
||||||
|
|
||||||
# search for end of body
|
# search for end of body
|
||||||
for l in f:
|
for line in f:
|
||||||
if l.strip() == "":
|
if line.strip() == "":
|
||||||
break
|
break
|
||||||
unsigned_file.append(l)
|
unsigned_file.append(line)
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
f = open(dscname, "w")
|
f = open(dscname, "w")
|
||||||
@ -160,7 +161,8 @@ def dsc_getfiles(dscurl):
|
|||||||
return files
|
return files
|
||||||
|
|
||||||
def add_fixed_bugs(changes, bugs, script_name=None, verbose=False):
|
def add_fixed_bugs(changes, bugs, script_name=None, verbose=False):
|
||||||
'''Add additional Launchpad bugs to the list of fixed bugs in changes file.'''
|
'''Add additional Launchpad bugs to the list of fixed bugs in changes
|
||||||
|
file.'''
|
||||||
|
|
||||||
changes = filter(lambda l: l.strip() != "", changes.split("\n"))
|
changes = filter(lambda l: l.strip() != "", changes.split("\n"))
|
||||||
# Remove duplicates
|
# Remove duplicates
|
||||||
@ -191,8 +193,8 @@ def sync_dsc(script_name, dscurl, debian_dist, release, name, email, bugs,
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
urllib.urlretrieve(dscurl, dscname)
|
urllib.urlretrieve(dscurl, dscname)
|
||||||
except IOError as e:
|
except IOError as error:
|
||||||
parameters = (script_name, dscname, e.errno, e.strerror)
|
parameters = (script_name, dscname, error.errno, error.strerror)
|
||||||
print >> sys.stderr, ("%s: Error: Failed to download %s "
|
print >> sys.stderr, ("%s: Error: Failed to download %s "
|
||||||
"[Errno %i]: %s.") % parameters
|
"[Errno %i]: %s.") % parameters
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -225,13 +227,13 @@ def sync_dsc(script_name, dscurl, debian_dist, release, name, email, bugs,
|
|||||||
(script_name, srcpkg, ubuntu_ver, new_ver)
|
(script_name, srcpkg, ubuntu_ver, new_ver)
|
||||||
|
|
||||||
files = dsc_getfiles(dscurl)
|
files = dsc_getfiles(dscurl)
|
||||||
source_files = filter(lambda f: f.is_source_file(), files)
|
source_files = [f for f in files if f.is_source_file()]
|
||||||
if verbose:
|
if verbose:
|
||||||
print '%s: D: Files: %s' % (script_name, str(map(lambda x: x.get_name(),
|
print '%s: D: Files: %s' % (script_name,
|
||||||
files)))
|
str([x.get_name() for x in files]))
|
||||||
print '%s: D: Source files: %s' % (script_name,
|
print '%s: D: Source files: %s' % \
|
||||||
str(map(lambda x: x.get_name(), source_files)))
|
(script_name, str([x.get_name() for x in source_files]))
|
||||||
map(lambda f: f.download(script_name, verbose), files)
|
[f.download(script_name, verbose) for f in files]
|
||||||
|
|
||||||
if ubuntu_dsc is None:
|
if ubuntu_dsc is None:
|
||||||
ubuntu_files = None
|
ubuntu_files = None
|
||||||
@ -245,7 +247,8 @@ def sync_dsc(script_name, dscurl, debian_dist, release, name, email, bugs,
|
|||||||
# We need to check if all .orig*.tar.* tarballs exist in Ubuntu
|
# We need to check if all .orig*.tar.* tarballs exist in Ubuntu
|
||||||
need_orig = False
|
need_orig = False
|
||||||
for source_file in source_files:
|
for source_file in source_files:
|
||||||
ubuntu_file = filter(lambda f: f.get_name() == source_file.get_name(),
|
ubuntu_file = filter(lambda f: f.get_name() ==
|
||||||
|
source_file.get_name(),
|
||||||
ubuntu_files)
|
ubuntu_files)
|
||||||
if len(ubuntu_file) == 0:
|
if len(ubuntu_file) == 0:
|
||||||
# The source file does not exist in Ubuntu
|
# The source file does not exist in Ubuntu
|
||||||
@ -286,7 +289,7 @@ def sync_dsc(script_name, dscurl, debian_dist, release, name, email, bugs,
|
|||||||
# Do a fake sync if required
|
# Do a fake sync if required
|
||||||
if len(fakesync_files) > 0:
|
if len(fakesync_files) > 0:
|
||||||
# Download Ubuntu files (override Debian source tarballs)
|
# Download Ubuntu files (override Debian source tarballs)
|
||||||
map(lambda f: f.download(script_name, verbose), fakesync_files)
|
[f.download(script_name, verbose) for f in fakesync_files]
|
||||||
|
|
||||||
# change into package directory
|
# change into package directory
|
||||||
directory = srcpkg + '-' + new_ver.upstream_version
|
directory = srcpkg + '-' + new_ver.upstream_version
|
||||||
@ -347,7 +350,7 @@ def sync_dsc(script_name, dscurl, debian_dist, release, name, email, bugs,
|
|||||||
changes_file = "%s_%s_source.changes" % (srcpkg, new_ver.strip_epoch())
|
changes_file = "%s_%s_source.changes" % (srcpkg, new_ver.strip_epoch())
|
||||||
if len(bugs) > 0:
|
if len(bugs) > 0:
|
||||||
message = "Fake sync due to mismatching orig tarball (LP: %s)." % \
|
message = "Fake sync due to mismatching orig tarball (LP: %s)." % \
|
||||||
(", ".join(map(lambda b: "#" + str(b), bugs)))
|
(", ".join(["#" + str(b) for b in bugs]))
|
||||||
else:
|
else:
|
||||||
message = "Fake sync due to mismatching orig tarball."
|
message = "Fake sync due to mismatching orig tarball."
|
||||||
cmd = ["dch", "-v", new_ver.full_version, "-D", release, message]
|
cmd = ["dch", "-v", new_ver.full_version, "-D", release, message]
|
||||||
@ -390,7 +393,8 @@ def get_debian_dscurl(package, dist, release, version=None, component=None):
|
|||||||
if version is None or component is None:
|
if version is None or component is None:
|
||||||
debian_srcpkg = getDebianSrcPkg(package, dist)
|
debian_srcpkg = getDebianSrcPkg(package, dist)
|
||||||
try:
|
try:
|
||||||
ubuntu_version = Version(getUbuntuSrcPkg(package, release).getVersion())
|
src_pkg = getUbuntuSrcPkg(package, release)
|
||||||
|
ubuntu_version = Version(src_pkg.getVersion())
|
||||||
except udtexceptions.PackageNotFoundException:
|
except udtexceptions.PackageNotFoundException:
|
||||||
ubuntu_version = Version('~')
|
ubuntu_version = Version('~')
|
||||||
if ubuntu_version >= Version(debian_srcpkg.getVersion()):
|
if ubuntu_version >= Version(debian_srcpkg.getVersion()):
|
||||||
@ -459,7 +463,7 @@ if __name__ == "__main__":
|
|||||||
"package names specified: %s") % parameters
|
"package names specified: %s") % parameters
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
invalid_bug_numbers = filter(lambda x: not x.isdigit(), options.bugs)
|
invalid_bug_numbers = [bug for bug in options.bugs if not bug.isdigit()]
|
||||||
if len(invalid_bug_numbers) > 0:
|
if len(invalid_bug_numbers) > 0:
|
||||||
print >> sys.stderr, "%s: Error: Invalid bug number(s) specified: %s" \
|
print >> sys.stderr, "%s: Error: Invalid bug number(s) specified: %s" \
|
||||||
% (script_name, ", ".join(invalid_bug_numbers))
|
% (script_name, ", ".join(invalid_bug_numbers))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user