diff options
author | Peter Maydell | 2018-06-12 12:56:20 +0200 |
---|---|---|
committer | Peter Maydell | 2018-06-12 12:56:21 +0200 |
commit | 5eca450b2ec219c4256062bfb5498c726c1ed0a4 (patch) | |
tree | 63bbbeb6fe3e21017c07eced27ee5ba34dc2d550 /tests/qemu-iotests/qcow2.py | |
parent | Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request... (diff) | |
parent | python: Remove scripts/ordereddict.py (diff) | |
download | qemu-5eca450b2ec219c4256062bfb5498c726c1ed0a4.tar.gz qemu-5eca450b2ec219c4256062bfb5498c726c1ed0a4.tar.xz qemu-5eca450b2ec219c4256062bfb5498c726c1ed0a4.zip |
Merge remote-tracking branch 'remotes/ehabkost/tags/python-next-pull-request' into staging
Python queue, 2018-06-11
* Make code compatible with Python 3 using 'futurize --stage1'
* Require Python >= 2.7 and remove Python 2.6 compatibility
modules
# gpg: Signature made Mon 11 Jun 2018 18:41:26 BST
# gpg: using RSA key 2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6
* remotes/ehabkost/tags/python-next-pull-request:
python: Remove scripts/ordereddict.py
python: Remove scripts/argparse.py
configure: Require Python 2.7 or newer
python: futurize -f lib2to3.fixes.fix_numliterals
python: futurize -f lib2to3.fixes.fix_except
python: futurize -f lib2to3.fixes.fix_renames
python: futurize -f lib2to3.fixes.fix_tuple_params
python: futurize -f lib2to3.fixes.fix_reduce
python: futurize -f lib2to3.fixes.fix_standarderror
python: futurize -f lib2to3.fixes.fix_has_key
python: futurize -f libfuturize.fixes.fix_next_call
python: futurize -f libfuturize.fixes.fix_absolute_import
python: futurize -f libfuturize.fixes.fix_print_with_import
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/qemu-iotests/qcow2.py')
-rwxr-xr-x | tests/qemu-iotests/qcow2.py | 39 |
1 files changed, 20 insertions, 19 deletions
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: |