ubuntu-bugcontrol team mailing list archive
-
ubuntu-bugcontrol team
-
Mailing list archive
-
Message #04632
[Merge] ~sespiros/ubuntu-qa-tools:python3-fixes into ubuntu-qa-tools:master
Spyros Seimenis has proposed merging ~sespiros/ubuntu-qa-tools:python3-fixes into ubuntu-qa-tools:master.
Requested reviews:
Ubuntu Bug Control (ubuntu-bugcontrol)
For more details, see:
https://code.launchpad.net/~sespiros/ubuntu-qa-tools/+git/ubuntu-qa-tools-1/+merge/442767
--
Your team Ubuntu Bug Control is requested to review the proposed merge of ~sespiros/ubuntu-qa-tools:python3-fixes into ubuntu-qa-tools:master.
diff --git a/common/lpl_common.py b/common/lpl_common.py
index 2d35bf0..6adf2b9 100644
--- a/common/lpl_common.py
+++ b/common/lpl_common.py
@@ -206,7 +206,12 @@ def open_url(opener, url):
return page
def chunked_read(response, chunk_size=8192, outfile=None, verbose=True):
- total_size = int(response.info().getheader('Content-Length').strip())
+ info = response.info()
+ if hasattr(info, 'getheader'):
+ header = info.getheader('Content-Length')
+ else:
+ header = response.headers.get('Content-Length')
+ total_size = int(header.strip())
bytes_so_far = 0
try:
diff --git a/security-tools/fetch-buildlogs b/security-tools/fetch-buildlogs
index 15756cd..c0cc003 100755
--- a/security-tools/fetch-buildlogs
+++ b/security-tools/fetch-buildlogs
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
#
# Downloads buildlog for more recent build
#
@@ -7,12 +7,16 @@
#
# TODO: handle not specifying pocket so we can just "get latest" of Release, Updates, Security
-import sys, optparse, time, os, tempfile, subprocess, shutil, urllib2, glob
+from __future__ import print_function
+
+import sys, optparse, time, os, tempfile, subprocess, shutil, urllib, glob
import lpl_common
import apt_pkg
from configobj import ConfigObj
import progressbar
+def eprint(*args, **kwargs):
+ print(*args, file=sys.stderr, **kwargs)
# Cookie for protected file downloads
config = ConfigObj(os.path.expanduser("~/.ubuntu-cve-tracker.conf"))
@@ -30,11 +34,11 @@ parser.add_option("-p","--pocket", help="Which release pocket to download logs f
(opt, args) = parser.parse_args()
if not opt.release:
- print >>sys.stderr, 'Usage: %s [OPTIONS] -r SERIES [PKG PKG ...]' % (sys.argv[0])
+ eprint('Usage: %s [OPTIONS] -r SERIES [PKG PKG ...]' % (sys.argv[0]))
sys.exit(1)
if opt.verbose:
- print "Loading Ubuntu Distribution ..."
+ print("Loading Ubuntu Distribution ...")
lp = lpl_common.connect()
ubuntu = lp.distributions['ubuntu']
archive, base_group, base_ppa = lpl_common.get_archive(opt.base, lp, opt.verbose, ubuntu)
@@ -105,32 +109,32 @@ components = set(opt.component.split(','))
for source_item in sources:
if not source_item.component_name in components:
if opt.verbose:
- print '%s (%s): %s' % (source_item.source_package_name, opt.release, source_item.component_name)
+ print('%s (%s): %s' % (source_item.source_package_name, opt.release, source_item.component_name))
continue
pkg_glob = '%s_*' % (source_item.source_package_name)
pkg_ver_glob = '%s_%s_*' % (source_item.source_package_name, source_item.source_package_version)
if len(glob.glob(pkg_ver_glob))==1:
if opt.verbose:
- print '%s: cached' % (source_item.source_package_name)
+ print('%s: cached' % (source_item.source_package_name))
continue
arch = 'i386'
if opt.verbose:
- print "%s: finding build ..." % (source_item.source_package_name)
+ print("%s: finding build ..." % (source_item.source_package_name))
try:
url, arch, state = get_build(source_item, arch)
except:
url, arch, state = (None, None, "Launchpad failure!")
if not url:
if not state in quiet_state or opt.verbose:
- print >>sys.stderr, "Skipping '%s' (%s): %s" % (source_item.source_package_name, arch, state)
+ eprint("Skipping '%s' (%s): %s" % (source_item.source_package_name, arch, state))
continue
# Clean up old builds
for oldlog in glob.glob(pkg_glob):
if opt.verbose:
- print " removing old build log '%s' ..." % (oldlog)
+ print(" removing old build log '%s' ..." % (oldlog))
if not opt.dry_run:
os.unlink(oldlog)
diff --git a/security-tools/fetch-debdiff b/security-tools/fetch-debdiff
index 051f58b..11386cd 100755
--- a/security-tools/fetch-debdiff
+++ b/security-tools/fetch-debdiff
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
#
# Downloads debdiff from Launchpad
#
@@ -7,10 +7,14 @@
# Based on work by: Kees Cook <kees@xxxxxxxxxx>
#
+from __future__ import print_function
+
import sys, optparse, time, os, tempfile, urllib
import lpl_common
from configobj import ConfigObj
+def eprint(*args, **kwargs):
+ print(*args, file=sys.stderr, **kwargs)
# Cookie for protected file downloads
config = ConfigObj(os.path.expanduser("~/.ubuntu-cve-tracker.conf"))
@@ -22,11 +26,11 @@ parser.add_option("-v","--verbose", help="Add additional reporting", action='sto
(opt, args) = parser.parse_args()
if not len(args):
- print >>sys.stderr, 'Usage: %s [OPTIONS] [PKG,VERSION PKG,VERSION ...]' % (sys.argv[0])
+ eprint('Usage: %s [OPTIONS] [PKG,VERSION PKG,VERSION ...]' % (sys.argv[0]))
sys.exit(1)
if opt.verbose:
- print "Loading Ubuntu Distribution ..."
+ print("Loading Ubuntu Distribution ...")
lp = lpl_common.connect()
ubuntu = lp.distributions['ubuntu']
archive, base_group, base_ppa = lpl_common.get_archive('ubuntu', lp, opt.verbose, ubuntu)
@@ -41,11 +45,11 @@ if len(args):
pkg, ver = i.split(',')
sources += archive.getPublishedSources(source_name=pkg, version=ver, exact_match=True)
- print "%s (%s):" % (pkg, ver)
+ print("%s (%s):" % (pkg, ver))
for s in sources:
url = s.packageDiffUrl(to_version=s.source_package_version)
if not url:
- print " No debdiff found?!"
+ print(" No debdiff found?!")
continue
if url not in debdiff_urls:
@@ -53,20 +57,20 @@ if len(args):
url = s.changesFileUrl()
if not url:
- print " No changes url found?!"
+ print(" No changes url found?!")
continue
if url not in debdiff_urls:
changes_urls.append(url)
- print " Component: %s" % s.component_name
- print " Pocket: %s" % s.pocket
+ print(" Component: %s" % s.component_name)
+ print(" Pocket: %s" % s.pocket)
for url in debdiff_urls:
- print " Debdiff:",
- lpl_common.download(opener, url)
+ print(" Debdiff:",
+ lpl_common.download(opener, url))
for url in changes_urls:
- print " Changes:",
- lpl_common.download(opener, url)
+ print(" Changes:",
+ lpl_common.download(opener, url))
- print ""
+ print("")
Follow ups