summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBrian May <brian@linuxpenguins.xyz>2018-07-15 09:37:12 +1000
committerBrian May <brian@linuxpenguins.xyz>2018-08-06 16:57:35 +1000
commitdbfa93c62253aab8e1ceb1c1ed578ae88c9dc8f7 (patch)
tree5eafb3a2eed75924c515b4bf0250d83d9fb67400 /lib
parent4b9d6d320f02267e1d5c2d6c21c69314197adc8e (diff)
Fix print statements for Python 3.6 compatibility
Diffstat (limited to 'lib')
-rw-r--r--lib/python/debian_support.py21
-rw-r--r--lib/python/secmaster.py3
-rw-r--r--lib/python/sectracker/repo.py2
-rw-r--r--lib/python/sectracker/xcollections.py2
-rw-r--r--lib/python/sectracker_test/run.py9
-rw-r--r--lib/python/sectracker_test/test_analyzers.py7
-rw-r--r--lib/python/sectracker_test/test_parsers.py8
-rw-r--r--lib/python/security_db.py97
8 files changed, 77 insertions, 72 deletions
diff --git a/lib/python/debian_support.py b/lib/python/debian_support.py
index e4bc12ee77..26ce3507cf 100644
--- a/lib/python/debian_support.py
+++ b/lib/python/debian_support.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+from __future__ import print_function
"""This module implements facilities to deal with Debian-specific metadata."""
@@ -320,7 +321,7 @@ def updateFile(remote, local, verbose=None):
local_file = file(local)
except IOError:
if verbose:
- print "updateFile: no local copy, downloading full file"
+ print("updateFile: no local copy, downloading full file")
return downloadFile(remote, local)
lines = local_file.readlines()
@@ -338,11 +339,11 @@ def updateFile(remote, local, verbose=None):
index_fields = list(PackageFile(index_name, index_url))
except ParseError:
if verbose:
- print "updateFile: could not interpret patch index file"
+ print("updateFile: could not interpret patch index file")
return downloadFile(remote, local)
except IOError:
if verbose:
- print "updateFile: could not download patch index file"
+ print("updateFile: could not download patch index file")
return downloadFile(remote, local)
for fields in index_fields:
@@ -351,7 +352,7 @@ def updateFile(remote, local, verbose=None):
(remote_hash, remote_size) = re_whitespace.split(value)
if local_hash == remote_hash:
if verbose:
- print "updateFile: local file is up-to-date"
+ print("updateFile: local file is up-to-date")
return lines
continue
@@ -379,16 +380,16 @@ def updateFile(remote, local, verbose=None):
continue
if verbose:
- print "updateFile: field %s ignored" % `field`
+ print("updateFile: field %s ignored" % repr(field))
if not patches_to_apply:
if verbose:
- print "updateFile: could not find historic entry", local_hash
+ print("updateFile: could not find historic entry", local_hash)
return downloadFile(remote, local)
for patch_name in patches_to_apply:
if verbose:
- print "updateFile: downloading patch " + `patch_name`
+ print("updateFile: downloading patch " + repr(patch_name))
try:
patch_contents = downloadGunzipLines(remote + '.diff/' + patch_name
+ '.gz')
@@ -396,15 +397,15 @@ def updateFile(remote, local, verbose=None):
return downloadFile(remote, local)
if readLinesSHA1(patch_contents ) != patch_hashes[patch_name]:
if verbose:
- print "updateFile: patch was garbled: " + repr(patch_name)
+ print("updateFile: patch was garbled: " + repr(patch_name))
return downloadFile(remote, local)
patchLines(lines, patchesFromEdScript(patch_contents))
new_hash = readLinesSHA1(lines)
if new_hash != remote_hash:
if verbose:
- print "updateFile: patch failed, got %s instead of %s" \
- % (new_hash, remote_hash)
+ print("updateFile: patch failed, got %s instead of %s"
+ % (new_hash, remote_hash))
return downloadFile(remote, local)
replaceFile(lines, local)
diff --git a/lib/python/secmaster.py b/lib/python/secmaster.py
index 73522d552d..f87cdfd1e4 100644
--- a/lib/python/secmaster.py
+++ b/lib/python/secmaster.py
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+from __future__ import print_function
# Name of the security-master host
HOST = "seger.debian.org"
@@ -55,4 +56,4 @@ def listqueue():
if __name__ == "__main__":
for pkg, archs in listqueue():
- print " ".join(pkg.astuple()), "=>", ", ".join(archs)
+ print(" ".join(pkg.astuple()), "=>", ", ".join(archs))
diff --git a/lib/python/sectracker/repo.py b/lib/python/sectracker/repo.py
index ab0c43d89b..a108de8c3b 100644
--- a/lib/python/sectracker/repo.py
+++ b/lib/python/sectracker/repo.py
@@ -251,7 +251,7 @@ class RepoCollection(object):
def warn(self, msg):
if self.verbose:
- print msg
+ print(msg)
class Config(object):
def __init__(self, config, root):
diff --git a/lib/python/sectracker/xcollections.py b/lib/python/sectracker/xcollections.py
index 4dbf38010e..2a63a0ee83 100644
--- a/lib/python/sectracker/xcollections.py
+++ b/lib/python/sectracker/xcollections.py
@@ -72,7 +72,7 @@ def namedtuple(typename, field_names, verbose=False):
for i, name in enumerate(field_names):
template += ' %s = _property(_itemgetter(%d))\n' % (name, i)
if verbose:
- print template
+ print(template)
# Execute the template string in a temporary namespace and
# support tracing utilities by setting a value for frame.f_globals['__name__']
diff --git a/lib/python/sectracker_test/run.py b/lib/python/sectracker_test/run.py
index 886eded6a8..44fa675fcb 100644
--- a/lib/python/sectracker_test/run.py
+++ b/lib/python/sectracker_test/run.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+from __future__ import print_function
if __name__ != "__main__":
raise Exception("run must be executed directly")
@@ -45,13 +46,13 @@ for name in files:
if name[-3:] != ".py" or name == "run.py":
continue
fullpath = "%s/%s" % (ourpath, name)
- print "* Running", name
+ print("* Running", name)
p = subprocess.Popen(("python", "--", fullpath), env=env)
ret = p.wait()
if ret != 0:
- print "Test exited with status", ret
- print
+ print("Test exited with status", ret)
+ print()
errors = errors or ret != 0
if errors:
- print "ERROR: some tests aborted with errors"
+ print("ERROR: some tests aborted with errors")
sys.exit(1)
diff --git a/lib/python/sectracker_test/test_analyzers.py b/lib/python/sectracker_test/test_analyzers.py
index 133c9386dd..e192945e2b 100644
--- a/lib/python/sectracker_test/test_analyzers.py
+++ b/lib/python/sectracker_test/test_analyzers.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+from __future__ import print_function
import os
@@ -43,7 +44,7 @@ if False:
for r, pv in rpv.items():
for p, v in pv.items():
if len(v) > 1:
- print r, p, v
+ print(r, p, v)
# copysources
copysrc = copysources(bugdb, diag)
@@ -54,12 +55,12 @@ assert "DSA-1472-1" in copysrc["CVE-2008-0225"]
vdb = fixedversions(bugdb, copysrc, rpv, diag)
if False:
for v in vdb:
- print v
+ print(v)
assert bestversion(c, "sid", "bash").name == "bash"
assert bestversion(c, "sid", "bash", ("unsupported", "supported")).name \
== "bash"
for err in diag.messages():
- print "%s:%d: %s: %s" % (err.file, err.line, err.level, err.message)
+ print("%s:%d: %s: %s" % (err.file, err.line, err.level, err.message))
assert not diag.messages()
diff --git a/lib/python/sectracker_test/test_parsers.py b/lib/python/sectracker_test/test_parsers.py
index 436b2f027c..970e9f4177 100644
--- a/lib/python/sectracker_test/test_parsers.py
+++ b/lib/python/sectracker_test/test_parsers.py
@@ -28,22 +28,22 @@ assert "bash" in o["bash"].binary
safeunlink("../../data/CVE/list" + EXTENSION)
o = cvelist("../../data/CVE/list")
for err in o.messages:
- print "%s:%d: %s: %s" % (err.file, err.line, err.level, err.message)
+ print("%s:%d: %s: %s" % (err.file, err.line, err.level, err.message))
safeunlink("../../data/DSA/list" + EXTENSION)
o = dsalist("../../data/DSA/list")
for err in o.messages:
- print "%s:%d: %s: %s" % (err.file, err.line, err.level, err.message)
+ print("%s:%d: %s: %s" % (err.file, err.line, err.level, err.message))
safeunlink("../../data/DTSA/list" + EXTENSION)
o = dtsalist("../../data/DTSA/list")
for err in o.messages:
- print "%s:%d: %s: %s" % (err.file, err.line, err.level, err.message)
+ print("%s:%d: %s: %s" % (err.file, err.line, err.level, err.message))
safeunlink("../../data/DLA/list" + EXTENSION)
o = dlalist("../../data/DLA/list")
for err in o.messages:
- print "%s:%d: %s: %s" % (err.file, err.line, err.level, err.message)
+ print("%s:%d: %s: %s" % (err.file, err.line, err.level, err.message))
Message = sectracker.diagnostics.Message
for (line, res, xmsgs) in [
diff --git a/lib/python/security_db.py b/lib/python/security_db.py
index 90529ad38d..84f62f0d65 100644
--- a/lib/python/security_db.py
+++ b/lib/python/security_db.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+from __future__ import print_function
"""This module implements a small database for tracking security bugs.
@@ -268,8 +269,8 @@ class DB:
c.execute("PRAGMA user_version = 22")
elif v != self.schema_version:
if self.verbose:
- print "DB: schema version mismatch: expected %d, got %d" \
- % (self.schema_version, v)
+ print("DB: schema version mismatch: expected %d, got %d"
+ % (self.schema_version, v))
raise SchemaMismatch(repr(v))
self._initViews(c)
return
@@ -633,7 +634,7 @@ class DB:
def do_parse(packages):
if self.verbose:
- print " reading " + `filename`
+ print(" reading " + repr(filename))
re_source = re.compile\
(r'^([a-zA-Z0-9.+-]+)(?:\s+\(([a-zA-Z0-9.+:~-]+)\))?$')
@@ -713,13 +714,13 @@ class DB:
"""Reads a directory of package files."""
if self.verbose:
- print "readPackages:"
+ print("readPackages:")
self._readSourcePackages(cursor, directory)
self._readBinaryPackages(cursor, directory)
if self.verbose:
- print " finished"
+ print(" finished")
def _readSourcePackages(self, cursor, directory):
"""Reads from directory with source package files."""
@@ -727,7 +728,7 @@ class DB:
re_sources = re.compile(r'.*/([a-z-]+)_([a-z-]*)_([a-z-]+)_Sources$')
if self.verbose:
- print " reading source packages"
+ print(" reading source packages")
for filename in glob.glob(directory + '/*_Sources'):
match = re_sources.match(filename)
@@ -768,7 +769,7 @@ class DB:
r'.*/([a-z-]+)_([a-z-]*)_([a-z-]+)_([a-z0-9-]+)_Packages$')
if self.verbose:
- print " reading binary packages"
+ print(" reading binary packages")
# First check for any changes.
@@ -786,7 +787,7 @@ class DB:
break
if not changed:
if self.verbose:
- print " finished (no changes)"
+ print(" finished (no changes)")
return
# Real import. We have to re-read all Packages files even if
@@ -825,11 +826,11 @@ class DB:
if unchanged:
if self.verbose:
- print " finished (no changes)"
+ print(" finished (no changes)")
return
if self.verbose:
- print " deleting old data"
+ print(" deleting old data")
cursor.execute("DELETE FROM binary_packages")
self._clearVersions(cursor)
@@ -847,7 +848,7 @@ class DB:
yield key + (archs,)
if self.verbose:
- print " storing binary package data"
+ print(" storing binary package data")
cursor.executemany(
"""INSERT INTO binary_packages
@@ -880,7 +881,7 @@ class DB:
def readBugs(self, cursor, path):
if self.verbose:
- print "readBugs:"
+ print("readBugs:")
def clear_db(cleared=[False]):
# Avoid clearing the database multiple times.
@@ -908,7 +909,7 @@ class DB:
clear_db()
if self.verbose:
- print " reading " + `source.name`
+ print(" reading " + repr(source.name))
for bug in source:
try:
@@ -945,7 +946,7 @@ class DB:
break
if unchanged:
if self.verbose:
- print " finished (no changes)"
+ print(" finished (no changes)")
return
clear_db()
@@ -966,13 +967,13 @@ class DB:
read_one(cls(path + srcpath))
if self.verbose:
- print " update removed packages"
+ print(" update removed packages")
self.readRemovedPackages(cursor, path + source_removed_packages)
errors = []
if self.verbose:
- print " check cross-references"
+ print(" check cross-references")
for (bug,) in cursor.execute(
"""SELECT DISTINCT target FROM bugs_xref
@@ -982,7 +983,7 @@ class DB:
errors.append("reference to unknown bug " + bug)
if self.verbose:
- print " copy notes"
+ print(" copy notes")
# Copy notes from DSA/DTSA/DLA to CVE.
@@ -1037,7 +1038,7 @@ class DB:
raise InsertError(errors)
if self.verbose:
- print " finished"
+ print(" finished")
def availableReleases(self, cursor=None):
"""Returns a list of tuples (RELEASE, ARCHIVE,
@@ -1088,15 +1089,15 @@ class DB:
"""Updates the linear version table."""
if self.verbose:
- print "updateVersions:"
+ print("updateVersions:")
for x in cursor.execute("SELECT * FROM version_linear_order LIMIT 1"):
if self.verbose:
- print " finished (no changes)"
+ print(" finished (no changes)")
return
if self.verbose:
- print " reading"
+ print(" reading")
versions = []
for (v,) in cursor.execute(
@@ -1107,18 +1108,18 @@ class DB:
versions.append(debian_support.Version(v))
if self.verbose:
- print " calculating linear order"
+ print(" calculating linear order")
versions.sort()
if self.verbose:
- print " storing linear order"
+ print(" storing linear order")
for v in versions:
cursor.execute(
"INSERT INTO version_linear_order (version) VALUES (?)",
(str(v),))
if self.verbose:
- print " updating package notes"
+ print(" updating package notes")
cursor.execute(
"""UPDATE package_notes
SET fixed_version_id = (SELECT id FROM version_linear_order
@@ -1126,14 +1127,14 @@ class DB:
WHERE fixed_version IS NOT NULL""")
if self.verbose:
- print " updating source packages"
+ print(" updating source packages")
cursor.execute(
"""UPDATE source_packages
SET version_id = (SELECT id FROM version_linear_order
WHERE version = source_packages.version)""")
if self.verbose:
- print " finished"
+ print(" finished")
def calculateVulnerabilities(self, cursor):
"""Calculate vulnerable packages.
@@ -1149,8 +1150,8 @@ class DB:
self._updateVersions(cursor)
if self.verbose:
- print "calculateVulnerabilities:"
- print " checking version consistency in package notes"
+ print("calculateVulnerabilities:")
+ print(" checking version consistency in package notes")
# The following does not work because stable->security ->
# testing -> unstable propagation is no longer available.
@@ -1175,7 +1176,7 @@ class DB:
% (b.source_file, b.source_line, `rel`, rel_ver))
if self.verbose:
- print " checking source packages"
+ print(" checking source packages")
cursor.execute(
"""UPDATE package_notes SET package_kind = 'unknown'
WHERE package_kind IN ('source', 'binary')""")
@@ -1206,13 +1207,13 @@ class DB:
return result
if self.verbose:
- print " remove old status"
+ print(" remove old status")
cursor.execute("DELETE FROM source_package_status")
cursor.execute("DELETE FROM bug_status")
if self.verbose:
- print " calculate package status"
- print " source packages (unqualified)"
+ print(" calculate package status")
+ print(" source packages (unqualified)")
cursor.execute(
"""INSERT INTO source_package_status
@@ -1229,7 +1230,7 @@ class DB:
# therefore we use INSERT OR REPLACE.
if self.verbose:
- print " source packages (qualified)"
+ print(" source packages (qualified)")
cursor.execute(
"""INSERT OR REPLACE INTO source_package_status
SELECT n.bug_name, p.rowid,
@@ -1244,7 +1245,7 @@ class DB:
# assign nvd urgencies to those that have not yet been assigned
if self.verbose:
- print " insert nvd urgencies"
+ print(" insert nvd urgencies")
cursor.execute(
"""REPLACE INTO source_package_status
SELECT s.bug_name, s.package, s.vulnerable,
@@ -1271,7 +1272,7 @@ class DB:
# Calculate the release-specific bug status.
if self.verbose:
- print " calculate release status"
+ print(" calculate release status")
c = self.cursor()
@@ -2095,13 +2096,13 @@ class DB:
AND sp.release = binary_packages.release
AND sp.archive = binary_packages.archive)
"""):
- print "error: binary package without source package"
- print " binary package:", package
- print " release:", release
+ print("error: binary package without source package")
+ print(" binary package:", package)
+ print(" release:", release)
if archive:
- print " archive:", archive
- print " architecture:", architecture
- print " missing source package:", source
+ print(" archive:", archive)
+ print(" architecture:", architecture)
+ print(" missing source package:", source)
for (package, release, archive, architecture, version,
source, source_version) \
@@ -2118,15 +2119,15 @@ class DB:
debian_support.Version(source_version))
assert relation != 0
if relation <= 0:
- print "error: binary package is older than source package"
+ print("error: binary package is older than source package")
else:
- print "warning: binary package is newer than source package"
- print " binary package: %s (%s)" % (package, version)
- print " source package: %s (%s)" % (source, source_version)
- print " release:", release
+ print("warning: binary package is newer than source package")
+ print(" binary package: %s (%s)" % (package, version))
+ print(" source package: %s (%s)" % (source, source_version))
+ print(" release:", release)
if archive:
- print " archive:", archive
- print " architecture:", architecture
+ print(" archive:", archive)
+ print(" architecture:", architecture)
def test():
assert mergeLists(u'',u'') == [], mergeLists(u'', u'')

© 2014-2024 Faster IT GmbH | imprint | privacy policy