diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2018-06-08 09:29:43 -0300 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2018-06-08 14:39:24 -0300 |
commit | f03868bd5653265e97b253102d77d83ea85efdea (patch) | |
tree | f524a2198bb8492e8502326a112d465892d255b0 /tests | |
parent | 0d2fa03dae4fbe185a082f361342b1e30aed4582 (diff) |
python: futurize -f libfuturize.fixes.fix_print_with_import
Change all Python code to use print as a function.
This is necessary for Python 3 compatibility.
Done using:
$ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
sort -u | grep -v README.sh4)
$ futurize -w -f libfuturize.fixes.fix_print_with_import $py
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20180608122952.2009-2-ehabkost@redhat.com>
[ehabkost: fixup tests/docker/docker.py]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/docker/docker.py | 17 | ||||
-rwxr-xr-x | tests/docker/travis.py | 15 | ||||
-rw-r--r-- | tests/guest-debug/test-gdbstub.py | 1 | ||||
-rwxr-xr-x | tests/image-fuzzer/runner.py | 38 | ||||
-rw-r--r-- | tests/migration/guestperf/engine.py | 29 | ||||
-rw-r--r-- | tests/migration/guestperf/plot.py | 17 | ||||
-rw-r--r-- | tests/migration/guestperf/shell.py | 19 | ||||
-rwxr-xr-x | tests/qemu-iotests/149 | 3 | ||||
-rwxr-xr-x | tests/qemu-iotests/165 | 3 | ||||
-rw-r--r-- | tests/qemu-iotests/iotests.py | 5 | ||||
-rwxr-xr-x | tests/qemu-iotests/nbd-fault-injector.py | 7 | ||||
-rwxr-xr-x | tests/qemu-iotests/qcow2.py | 39 | ||||
-rwxr-xr-x | tests/qemu-iotests/qed.py | 17 | ||||
-rwxr-xr-x | tests/vm/basevm.py | 3 |
14 files changed, 110 insertions, 103 deletions
diff --git a/tests/docker/docker.py b/tests/docker/docker.py index f8267586eb..306e14cf69 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -11,6 +11,7 @@ # or (at your option) any later version. See the COPYING file in # the top-level directory. +from __future__ import print_function import os import sys sys.path.append(os.path.join(os.path.dirname(__file__), @@ -87,7 +88,7 @@ def _get_so_libs(executable): so_lib = search.groups()[1] libs.append("%s/%s" % (so_path, so_lib)) except subprocess.CalledProcessError: - print "%s had no associated libraries (static build?)" % (executable) + print("%s had no associated libraries (static build?)" % (executable)) return libs @@ -161,7 +162,7 @@ class Docker(object): continue if only_known and instance_uuid not in self._instances: continue - print "Terminating", i + print("Terminating", i) if active: self._do(["kill", i]) self._do(["rm", i]) @@ -288,7 +289,7 @@ class BuildCommand(SubCommand): if "--no-cache" not in argv and \ dkr.image_matches_dockerfile(tag, dockerfile): if not args.quiet: - print "Image is up to date." + print("Image is up to date.") else: # Create a docker context directory for the build docker_dir = tempfile.mkdtemp(prefix="docker_build") @@ -300,10 +301,10 @@ class BuildCommand(SubCommand): rc = subprocess.call(os.path.realpath(docker_pre), cwd=docker_dir, stdout=stdout) if rc == 3: - print "Skip" + print("Skip") return 0 elif rc != 0: - print "%s exited with code %d" % (docker_pre, rc) + print("%s exited with code %d" % (docker_pre, rc)) return 1 # Copy any extra files into the Docker context. These can be @@ -399,11 +400,11 @@ class ProbeCommand(SubCommand): try: docker = Docker() if docker._command[0] == "docker": - print "yes" + print("yes") elif docker._command[0] == "sudo": - print "sudo" + print("sudo") except Exception: - print "no" + print("no") return diff --git a/tests/docker/travis.py b/tests/docker/travis.py index 703a7fde85..ea1ef169e6 100755 --- a/tests/docker/travis.py +++ b/tests/docker/travis.py @@ -11,6 +11,7 @@ # or (at your option) any later version. See the COPYING file in # the top-level directory. +from __future__ import print_function import sys import yaml import itertools @@ -34,14 +35,14 @@ def main(): sys.stderr.write("Usage: %s <travis-file>\n" % sys.argv[0]) return 1 conf = load_yaml(sys.argv[1]) - print "\n".join((": ${%s}" % var for var in conf["env"]["global"])) + print("\n".join((": ${%s}" % var for var in conf["env"]["global"]))) for config in conf_iter(conf): - print "(" - print "\n".join(config["env"]) - print "alias cc=" + config["compiler"] - print "\n".join(conf["before_script"]) - print "\n".join(conf["script"]) - print ")" + print("(") + print("\n".join(config["env"])) + print("alias cc=" + config["compiler"]) + print("\n".join(conf["before_script"])) + print("\n".join(conf["script"])) + print(")") return 0 if __name__ == "__main__": diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py index 31ba6c943a..474d2c5c65 100644 --- a/tests/guest-debug/test-gdbstub.py +++ b/tests/guest-debug/test-gdbstub.py @@ -1,3 +1,4 @@ +from __future__ import print_function # # This script needs to be run on startup # qemu -kernel ${KERNEL} -s -S diff --git a/tests/image-fuzzer/runner.py b/tests/image-fuzzer/runner.py index 96a1c11b2f..8de656933e 100755 --- a/tests/image-fuzzer/runner.py +++ b/tests/image-fuzzer/runner.py @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function import sys import os import signal @@ -36,9 +37,8 @@ except ImportError: try: import simplejson as json except ImportError: - print >>sys.stderr, \ - "Warning: Module for JSON processing is not found.\n" \ - "'--config' and '--command' options are not supported." + print("Warning: Module for JSON processing is not found.\n" \ + "'--config' and '--command' options are not supported.", file=sys.stderr) # Backing file sizes in MB MAX_BACKING_FILE_SIZE = 10 @@ -158,9 +158,8 @@ class TestEnv(object): try: os.makedirs(self.current_dir) except OSError as e: - print >>sys.stderr, \ - "Error: The working directory '%s' cannot be used. Reason: %s"\ - % (self.work_dir, e[1]) + print("Error: The working directory '%s' cannot be used. Reason: %s"\ + % (self.work_dir, e[1]), file=sys.stderr) raise TestException self.log = open(os.path.join(self.current_dir, "test.log"), "w") self.parent_log = open(run_log, "a") @@ -277,7 +276,7 @@ class TestEnv(object): if __name__ == '__main__': def usage(): - print """ + print(""" Usage: runner.py [OPTION...] TEST_DIR IMG_GENERATOR Set up test environment in TEST_DIR and run a test in it. A module for @@ -326,7 +325,7 @@ if __name__ == '__main__': If '--config' argument is specified, fields not listed in the configuration array will not be fuzzed. - """ + """) def run_test(test_id, seed, work_dir, run_log, cleanup, log_all, command, fuzz_config): @@ -357,8 +356,7 @@ if __name__ == '__main__': ['command=', 'help', 'seed=', 'config=', 'keep_passed', 'verbose', 'duration=']) except getopt.error as e: - print >>sys.stderr, \ - "Error: %s\n\nTry 'runner.py --help' for more information" % e + print("Error: %s\n\nTry 'runner.py --help' for more information" % e, file=sys.stderr) sys.exit(1) command = None @@ -375,9 +373,8 @@ if __name__ == '__main__': try: command = json.loads(arg) except (TypeError, ValueError, NameError) as e: - print >>sys.stderr, \ - "Error: JSON array of test commands cannot be loaded.\n" \ - "Reason: %s" % e + print("Error: JSON array of test commands cannot be loaded.\n" \ + "Reason: %s" % e, file=sys.stderr) sys.exit(1) elif opt in ('-k', '--keep_passed'): cleanup = False @@ -391,15 +388,13 @@ if __name__ == '__main__': try: config = json.loads(arg) except (TypeError, ValueError, NameError) as e: - print >>sys.stderr, \ - "Error: JSON array with the fuzzer configuration cannot" \ - " be loaded\nReason: %s" % e + print("Error: JSON array with the fuzzer configuration cannot" \ + " be loaded\nReason: %s" % e, file=sys.stderr) sys.exit(1) if not len(args) == 2: - print >>sys.stderr, \ - "Expected two parameters\nTry 'runner.py --help'" \ - " for more information." + print("Expected two parameters\nTry 'runner.py --help'" \ + " for more information.", file=sys.stderr) sys.exit(1) work_dir = os.path.realpath(args[0]) @@ -415,9 +410,8 @@ if __name__ == '__main__': try: image_generator = __import__(generator_name) except ImportError as e: - print >>sys.stderr, \ - "Error: The image generator '%s' cannot be imported.\n" \ - "Reason: %s" % (generator_name, e) + print("Error: The image generator '%s' cannot be imported.\n" \ + "Reason: %s" % (generator_name, e), file=sys.stderr) sys.exit(1) # Enable core dumps diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestperf/engine.py index e14d4320b2..398e3f2706 100644 --- a/tests/migration/guestperf/engine.py +++ b/tests/migration/guestperf/engine.py @@ -1,3 +1,4 @@ +from __future__ import print_function # # Migration test main engine # @@ -117,7 +118,7 @@ class Engine(object): # XXX how to get dst timings on remote host ? if self._verbose: - print "Sleeping %d seconds for initial guest workload run" % self._sleep + print("Sleeping %d seconds for initial guest workload run" % self._sleep) sleep_secs = self._sleep while sleep_secs > 1: src_qemu_time.append(self._cpu_timing(src_pid)) @@ -126,7 +127,7 @@ class Engine(object): sleep_secs -= 1 if self._verbose: - print "Starting migration" + print("Starting migration") if scenario._auto_converge: resp = src.command("migrate-set-capabilities", capabilities = [ @@ -216,7 +217,7 @@ class Engine(object): if progress._status == "completed": if self._verbose: - print "Sleeping %d seconds for final guest workload run" % self._sleep + print("Sleeping %d seconds for final guest workload run" % self._sleep) sleep_secs = self._sleep while sleep_secs > 1: time.sleep(1) @@ -227,23 +228,23 @@ class Engine(object): return [progress_history, src_qemu_time, src_vcpu_time] if self._verbose and (loop % 20) == 0: - print "Iter %d: remain %5dMB of %5dMB (total %5dMB @ %5dMb/sec)" % ( + print("Iter %d: remain %5dMB of %5dMB (total %5dMB @ %5dMb/sec)" % ( progress._ram._iterations, progress._ram._remaining_bytes / (1024 * 1024), progress._ram._total_bytes / (1024 * 1024), progress._ram._transferred_bytes / (1024 * 1024), progress._ram._transfer_rate_mbs, - ) + )) if progress._ram._iterations > scenario._max_iters: if self._verbose: - print "No completion after %d iterations over RAM" % scenario._max_iters + print("No completion after %d iterations over RAM" % scenario._max_iters) src.command("migrate_cancel") continue if time.time() > (start + scenario._max_time): if self._verbose: - print "No completion after %d seconds" % scenario._max_time + print("No completion after %d seconds" % scenario._max_time) src.command("migrate_cancel") continue @@ -251,7 +252,7 @@ class Engine(object): progress._ram._iterations >= scenario._post_copy_iters and not post_copy): if self._verbose: - print "Switching to post-copy after %d iterations" % scenario._post_copy_iters + print("Switching to post-copy after %d iterations" % scenario._post_copy_iters) resp = src.command("migrate-start-postcopy") post_copy = True @@ -259,7 +260,7 @@ class Engine(object): progress._ram._iterations >= scenario._pause_iters and not paused): if self._verbose: - print "Pausing VM after %d iterations" % scenario._pause_iters + print("Pausing VM after %d iterations" % scenario._pause_iters) resp = src.command("stop") paused = True @@ -348,7 +349,7 @@ class Engine(object): if not log: return [] if self._debug: - print log + print(log) regex = r"[^\s]+\s\((\d+)\):\sINFO:\s(\d+)ms\scopied\s\d+\sGB\sin\s(\d+)ms" matcher = re.compile(regex) @@ -407,7 +408,7 @@ class Engine(object): if uri[0:5] == "unix:": os.remove(uri[5:]) if self._verbose: - print "Finished migration" + print("Finished migration") src.shutdown() dst.shutdown() @@ -420,7 +421,7 @@ class Engine(object): self._initrd, self._transport, self._sleep) except Exception as e: if self._debug: - print "Failed: %s" % str(e) + print("Failed: %s" % str(e)) try: src.shutdown() except: @@ -431,7 +432,7 @@ class Engine(object): pass if self._debug: - print src.get_log() - print dst.get_log() + print(src.get_log()) + print(dst.get_log()) raise diff --git a/tests/migration/guestperf/plot.py b/tests/migration/guestperf/plot.py index bc42249e16..aa98912a82 100644 --- a/tests/migration/guestperf/plot.py +++ b/tests/migration/guestperf/plot.py @@ -1,3 +1,4 @@ +from __future__ import print_function # # Migration test graph plotting # @@ -588,7 +589,7 @@ class Plot(object): """ def generate_html(self, fh): - print >>fh, """<html> + print("""<html> <head> <script type="text/javascript" src="plotly.min.js"> </script> @@ -601,19 +602,19 @@ class Plot(object): <h1>Migration report</h1> <h2>Chart summary</h2> <div id="chart"> -""" % self._generate_style() - print >>fh, self._generate_chart() - print >>fh, """ +""" % self._generate_style(), file=fh) + print(self._generate_chart(), file=fh) + print(""" </div> <h2>Report details</h2> <div id="report"> -""" - print >>fh, self._generate_report() - print >>fh, """ +""", file=fh) + print(self._generate_report(), file=fh) + print(""" </div> </body> </html> -""" +""", file=fh) def generate(self, filename): if filename is None: diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf/shell.py index b272978f47..a6b8cec1e0 100644 --- a/tests/migration/guestperf/shell.py +++ b/tests/migration/guestperf/shell.py @@ -1,3 +1,4 @@ +from __future__ import print_function # # Migration test command line shell integration # @@ -160,13 +161,13 @@ class Shell(BaseShell): try: report = engine.run(hardware, scenario) if args.output is None: - print report.to_json() + print(report.to_json()) else: with open(args.output, "w") as fh: - print >>fh, report.to_json() + print(report.to_json(), file=fh) return 0 except Exception as e: - print >>sys.stderr, "Error: %s" % str(e) + print("Error: %s" % str(e), file=sys.stderr) if args.debug: raise return 1 @@ -199,11 +200,11 @@ class BatchShell(BaseShell): name = os.path.join(comparison._name, scenario._name) if not fnmatch.fnmatch(name, args.filter): if args.verbose: - print "Skipping %s" % name + print("Skipping %s" % name) continue if args.verbose: - print "Running %s" % name + print("Running %s" % name) dirname = os.path.join(args.output, comparison._name) filename = os.path.join(dirname, scenario._name + ".json") @@ -211,9 +212,9 @@ class BatchShell(BaseShell): os.makedirs(dirname) report = engine.run(hardware, scenario) with open(filename, "w") as fh: - print >>fh, report.to_json() + print(report.to_json(), file=fh) except Exception as e: - print >>sys.stderr, "Error: %s" % str(e) + print("Error: %s" % str(e), file=sys.stderr) if args.debug: raise @@ -246,14 +247,14 @@ class PlotShell(object): if len(args.reports) == 0: - print >>sys.stderr, "At least one report required" + print("At least one report required", file=sys.stderr) return 1 if not (args.qemu_cpu or args.vcpu_cpu or args.total_guest_cpu or args.split_guest_cpu): - print >>sys.stderr, "At least one chart type is required" + print("At least one chart type is required", file=sys.stderr) return 1 reports = [] diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149 index 223cd68ad5..d3ffa259db 100755 --- a/tests/qemu-iotests/149 +++ b/tests/qemu-iotests/149 @@ -20,6 +20,7 @@ # Exercise the QEMU 'luks' block driver to validate interoperability # with the Linux dm-crypt + cryptsetup implementation +from __future__ import print_function import subprocess import os import os.path @@ -376,7 +377,7 @@ def test_once(config, qemu_img=False): finally: iotests.log("# Delete image") delete_image(config) - print + print() # Obviously we only work with the luks image format diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165 index 2936929627..88f62d3c6d 100755 --- a/tests/qemu-iotests/165 +++ b/tests/qemu-iotests/165 @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function import os import re import iotests @@ -85,7 +86,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log) log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log) if log: - print log + print(log) self.vm = self.mkVm() self.vm.launch() diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index fdbdd8b300..fd8f79fef9 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Common utilities and Python wrappers for qemu-iotests # # Copyright (C) 2012 IBM Corp. @@ -239,7 +240,7 @@ def filter_img_info(output, filename): def log(msg, filters=[]): for flt in filters: msg = flt(msg) - print msg + print(msg) class Timeout: def __init__(self, seconds, errmsg = "Timeout"): @@ -599,7 +600,7 @@ def notrun(reason): seq = os.path.basename(sys.argv[0]) open('%s/%s.notrun' % (output_dir, seq), 'wb').write(reason + '\n') - print '%s not run: %s' % (seq, reason) + print('%s not run: %s' % (seq, reason)) sys.exit(0) def verify_image_format(supported_fmts=[], unsupported_fmts=[]): diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py index 8a04d979aa..f9193c0fae 100755 --- a/tests/qemu-iotests/nbd-fault-injector.py +++ b/tests/qemu-iotests/nbd-fault-injector.py @@ -43,6 +43,7 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +from __future__ import print_function import sys import socket import struct @@ -110,7 +111,7 @@ class FaultInjectionSocket(object): for rule in self.rules: if rule.match(event, io): if rule.when == 0 or bufsize is None: - print 'Closing connection on rule match %s' % rule.name + print('Closing connection on rule match %s' % rule.name) sys.exit(0) if rule.when != -1: return rule.when @@ -182,7 +183,7 @@ def handle_connection(conn, use_export): elif req.type == NBD_CMD_DISC: break else: - print 'unrecognized command type %#02x' % req.type + print('unrecognized command type %#02x' % req.type) break conn.close() @@ -242,7 +243,7 @@ def open_socket(path): sock = socket.socket(socket.AF_UNIX) sock.bind(path) sock.listen(0) - print 'Listening on %s' % path + print('Listening on %s' % path) sys.stdout.flush() # another process may be waiting, show message now return sock diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py index 9cc4cf7d08..b95a837759 100755 --- a/tests/qemu-iotests/qcow2.py +++ b/tests/qemu-iotests/qcow2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function import sys import struct import string @@ -129,8 +130,8 @@ class QcowHeader: def dump(self): for f in QcowHeader.fields: - print "%-25s" % f[2], f[1] % self.__dict__[f[2]] - print "" + print("%-25s" % f[2], f[1] % self.__dict__[f[2]]) + print("") def dump_extensions(self): for ex in self.extensions: @@ -141,11 +142,11 @@ class QcowHeader: else: data = "<binary>" - print "Header extension:" - print "%-25s %#x" % ("magic", ex.magic) - print "%-25s %d" % ("length", ex.length) - print "%-25s %s" % ("data", data) - print "" + print("Header extension:") + print("%-25s %#x" % ("magic", ex.magic)) + print("%-25s %d" % ("length", ex.length)) + print("%-25s %s" % ("data", data)) + print("") def cmd_dump_header(fd): @@ -157,12 +158,12 @@ def cmd_set_header(fd, name, value): try: value = int(value, 0) except: - print "'%s' is not a valid number" % value + print("'%s' is not a valid number" % value) sys.exit(1) fields = (field[2] for field in QcowHeader.fields) if not name in fields: - print "'%s' is not a known header field" % name + print("'%s' is not a known header field" % name) sys.exit(1) h = QcowHeader(fd) @@ -173,7 +174,7 @@ def cmd_add_header_ext(fd, magic, data): try: magic = int(magic, 0) except: - print "'%s' is not a valid magic number" % magic + print("'%s' is not a valid magic number" % magic) sys.exit(1) h = QcowHeader(fd) @@ -188,7 +189,7 @@ def cmd_del_header_ext(fd, magic): try: magic = int(magic, 0) except: - print "'%s' is not a valid magic number" % magic + print("'%s' is not a valid magic number" % magic) sys.exit(1) h = QcowHeader(fd) @@ -200,7 +201,7 @@ def cmd_del_header_ext(fd, magic): h.extensions.remove(ex) if not found: - print "No such header extension" + print("No such header extension") return h.update(fd) @@ -211,7 +212,7 @@ def cmd_set_feature_bit(fd, group, bit): if bit < 0 or bit >= 64: raise ValueError except: - print "'%s' is not a valid bit number in range [0, 64)" % bit + print("'%s' is not a valid bit number in range [0, 64)" % bit) sys.exit(1) h = QcowHeader(fd) @@ -222,7 +223,7 @@ def cmd_set_feature_bit(fd, group, bit): elif group == 'autoclear': h.autoclear_features |= 1 << bit else: - print "'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group + print("'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group) sys.exit(1) h.update(fd) @@ -248,16 +249,16 @@ def main(filename, cmd, args): else: handler(fd, *args) return - print "Unknown command '%s'" % cmd + print("Unknown command '%s'" % cmd) finally: fd.close() def usage(): - print "Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0] - print "" - print "Supported commands:" + print("Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0]) + print("") + print("Supported commands:") for name, handler, num_args, desc in cmds: - print " %-20s - %s" % (name, desc) + print(" %-20s - %s" % (name, desc)) if __name__ == '__main__': if len(sys.argv) < 3: diff --git a/tests/qemu-iotests/qed.py b/tests/qemu-iotests/qed.py index 748068d7fe..ea469b9c48 100755 --- a/tests/qemu-iotests/qed.py +++ b/tests/qemu-iotests/qed.py @@ -10,6 +10,7 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +from __future__ import print_function import sys import struct import random @@ -108,12 +109,12 @@ def corrupt_table_invalidate(qed, table): def cmd_show(qed, *args): '''show [header|l1|l2 <offset>]- Show header or l1/l2 tables''' if not args or args[0] == 'header': - print qed.header + print(qed.header) elif args[0] == 'l1': - print qed.l1_table + print(qed.l1_table) elif len(args) == 2 and args[0] == 'l2': offset = int(args[1]) - print qed.read_table(offset) + print(qed.read_table(offset)) else: err('unrecognized sub-command') @@ -146,7 +147,7 @@ def cmd_invalidate(qed, table_level): def cmd_need_check(qed, *args): '''need-check [on|off] - Test, set, or clear the QED_F_NEED_CHECK header bit''' if not args: - print bool(qed.header['features'] & QED_F_NEED_CHECK) + print(bool(qed.header['features'] & QED_F_NEED_CHECK)) return if args[0] == 'on': @@ -208,11 +209,11 @@ def cmd_copy_metadata(qed, outfile): out.close() def usage(): - print 'Usage: %s <file> <cmd> [<arg>, ...]' % sys.argv[0] - print - print 'Supported commands:' + print('Usage: %s <file> <cmd> [<arg>, ...]' % sys.argv[0]) + print() + print('Supported commands:') for cmd in sorted(x for x in globals() if x.startswith('cmd_')): - print globals()[cmd].__doc__ + print(globals()[cmd].__doc__) sys.exit(1) def main(): diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 3a2d508c35..3643117816 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -11,6 +11,7 @@ # the COPYING file in the top-level directory. # +from __future__ import print_function import os import sys import logging @@ -222,7 +223,7 @@ def main(vmcls): try: args, argv = parse_args(vmcls.name) if not argv and not args.build_qemu and not args.build_image: - print "Nothing to do?" + print("Nothing to do?") return 1 logging.basicConfig(level=(logging.DEBUG if args.debug else logging.WARN)) |