Skip to content

Commit

Permalink
python: futurize -f libfuturize.fixes.fix_print_with_import
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ehabkost committed Jun 8, 2018
1 parent 0d2fa03 commit f03868b
Show file tree
Hide file tree
Showing 32 changed files with 281 additions and 256 deletions.
89 changes: 45 additions & 44 deletions scripts/analyse-9p-simpletrace.py
Expand Up @@ -3,6 +3,7 @@
# Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
#
# Author: Harsh Prateek Bora
from __future__ import print_function
import os
import simpletrace

Expand Down Expand Up @@ -79,135 +80,135 @@

class VirtFSRequestTracker(simpletrace.Analyzer):
def begin(self):
print "Pretty printing 9p simpletrace log ..."
print("Pretty printing 9p simpletrace log ...")

def v9fs_rerror(self, tag, id, err):
print "RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")"
print("RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")")

def v9fs_version(self, tag, id, msize, version):
print "TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")"
print("TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")

def v9fs_version_return(self, tag, id, msize, version):
print "RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")"
print("RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")

def v9fs_attach(self, tag, id, fid, afid, uname, aname):
print "TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")"
print("TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")")

def v9fs_attach_return(self, tag, id, type, version, path):
print "RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})"
print("RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")

def v9fs_stat(self, tag, id, fid):
print "TSTAT (tag =", tag, ", fid =", fid, ")"
print("TSTAT (tag =", tag, ", fid =", fid, ")")

def v9fs_stat_return(self, tag, id, mode, atime, mtime, length):
print "RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")"
print("RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")")

def v9fs_getattr(self, tag, id, fid, request_mask):
print "TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")"
print("TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")")

def v9fs_getattr_return(self, tag, id, result_mask, mode, uid, gid):
print "RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")"
print("RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")")

def v9fs_walk(self, tag, id, fid, newfid, nwnames):
print "TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")"
print("TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")")

def v9fs_walk_return(self, tag, id, nwnames, qids):
print "RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")"
print("RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")")

def v9fs_open(self, tag, id, fid, mode):
print "TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")"
print("TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")")

def v9fs_open_return(self, tag, id, type, version, path, iounit):
print "ROPEN (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
print("ROPEN (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")

def v9fs_lcreate(self, tag, id, dfid, flags, mode, gid):
print "TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")"
print("TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")")

def v9fs_lcreate_return(self, tag, id, type, version, path, iounit):
print "RLCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
print("RLCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")

def v9fs_fsync(self, tag, id, fid, datasync):
print "TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")"
print("TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")")

def v9fs_clunk(self, tag, id, fid):
print "TCLUNK (tag =", tag, ", fid =", fid, ")"
print("TCLUNK (tag =", tag, ", fid =", fid, ")")

def v9fs_read(self, tag, id, fid, off, max_count):
print "TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")"
print("TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")")

def v9fs_read_return(self, tag, id, count, err):
print "RREAD (tag =", tag, ", count =", count, ", err =", err, ")"
print("RREAD (tag =", tag, ", count =", count, ", err =", err, ")")

def v9fs_readdir(self, tag, id, fid, offset, max_count):
print "TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")"
print("TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")")

def v9fs_readdir_return(self, tag, id, count, retval):
print "RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")"
print("RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")")

def v9fs_write(self, tag, id, fid, off, count, cnt):
print "TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")"
print("TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")")

def v9fs_write_return(self, tag, id, total, err):
print "RWRITE (tag =", tag, ", total =", total, ", err =", err, ")"
print("RWRITE (tag =", tag, ", total =", total, ", err =", err, ")")

def v9fs_create(self, tag, id, fid, name, perm, mode):
print "TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")"
print("TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")")

def v9fs_create_return(self, tag, id, type, version, path, iounit):
print "RCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
print("RCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")

def v9fs_symlink(self, tag, id, fid, name, symname, gid):
print "TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")"
print("TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")")

def v9fs_symlink_return(self, tag, id, type, version, path):
print "RSYMLINK (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})"
print("RSYMLINK (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")

def v9fs_flush(self, tag, id, flush_tag):
print "TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")"
print("TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")")

def v9fs_link(self, tag, id, dfid, oldfid, name):
print "TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")"
print("TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")")

def v9fs_remove(self, tag, id, fid):
print "TREMOVE (tag =", tag, ", fid =", fid, ")"
print("TREMOVE (tag =", tag, ", fid =", fid, ")")

def v9fs_wstat(self, tag, id, fid, mode, atime, mtime):
print "TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")"
print("TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")")

def v9fs_mknod(self, tag, id, fid, mode, major, minor):
print "TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")"
print("TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")")

def v9fs_lock(self, tag, id, fid, type, start, length):
print "TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")"
print("TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")

def v9fs_lock_return(self, tag, id, status):
print "RLOCK (tag =", tag, ", status =", status, ")"
print("RLOCK (tag =", tag, ", status =", status, ")")

def v9fs_getlock(self, tag, id, fid, type, start, length):
print "TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")"
print("TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")

def v9fs_getlock_return(self, tag, id, type, start, length, proc_id):
print "RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id, ")"
print("RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id, ")")

def v9fs_mkdir(self, tag, id, fid, name, mode, gid):
print "TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")"
print("TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")")

def v9fs_mkdir_return(self, tag, id, type, version, path, err):
print "RMKDIR (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")"
print("RMKDIR (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")")

def v9fs_xattrwalk(self, tag, id, fid, newfid, name):
print "TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")"
print("TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")")

def v9fs_xattrwalk_return(self, tag, id, size):
print "RXATTRWALK (tag =", tag, ", xattrsize =", size, ")"
print("RXATTRWALK (tag =", tag, ", xattrsize =", size, ")")

def v9fs_xattrcreate(self, tag, id, fid, name, size, flags):
print "TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")"
print("TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")")

def v9fs_readlink(self, tag, id, fid):
print "TREADLINK (tag =", tag, ", fid =", fid, ")"
print("TREADLINK (tag =", tag, ", fid =", fid, ")")

def v9fs_readlink_return(self, tag, id, target):
print "RREADLINK (tag =", tag, ", target =", target, ")"
print("RREADLINK (tag =", tag, ", target =", target, ")")

simpletrace.run(VirtFSRequestTracker())
1 change: 1 addition & 0 deletions scripts/analyse-locks-simpletrace.py
Expand Up @@ -6,6 +6,7 @@
# Author: Alex Bennée <alex.bennee@linaro.org>
#

from __future__ import print_function
import os
import simpletrace
import argparse
Expand Down
11 changes: 6 additions & 5 deletions scripts/analyze-migration.py
Expand Up @@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import numpy as np
import json
import os
Expand Down Expand Up @@ -162,7 +163,7 @@ def read(self):
len = self.file.read64()
self.sizeinfo[self.name] = '0x%016x' % len
if self.write_memory:
print self.name
print(self.name)
mkdir_p('./' + os.path.dirname(self.name))
f = open('./' + self.name, "wb")
f.truncate(0)
Expand Down Expand Up @@ -588,15 +589,15 @@ def default(self, o):
dump = MigrationDump(args.file)

dump.read(desc_only = True)
print "desc.json"
print("desc.json")
f = open("desc.json", "wb")
f.truncate()
f.write(jsonenc.encode(dump.vmsd_desc))
f.close()

dump.read(write_memory = True)
dict = dump.getDict()
print "state.json"
print("state.json")
f = open("state.json", "wb")
f.truncate()
f.write(jsonenc.encode(dict))
Expand All @@ -605,10 +606,10 @@ def default(self, o):
dump = MigrationDump(args.file)
dump.read(dump_memory = args.memory)
dict = dump.getDict()
print jsonenc.encode(dict)
print(jsonenc.encode(dict))
elif args.dump == "desc":
dump = MigrationDump(args.file)
dump.read(desc_only = True)
print jsonenc.encode(dump.vmsd_desc)
print(jsonenc.encode(dump.vmsd_desc))
else:
raise Exception("Please specify either -x, -d state or -d dump")
3 changes: 2 additions & 1 deletion scripts/device-crash-test
Expand Up @@ -23,6 +23,7 @@
Run QEMU with all combinations of -machine and -device types,
check for crashes and unexpected errors.
"""
from __future__ import print_function

import sys
import os
Expand Down Expand Up @@ -554,7 +555,7 @@ def main():
tc[k] = v

if len(binariesToTest(args, tc)) == 0:
print >>sys.stderr, "No QEMU binary found"
print("No QEMU binary found", file=sys.stderr)
parser.print_usage(sys.stderr)
return 1

Expand Down
1 change: 1 addition & 0 deletions scripts/dump-guest-memory.py
Expand Up @@ -12,6 +12,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 ctypes
import struct
Expand Down
21 changes: 11 additions & 10 deletions scripts/kvm/kvm_flightrecorder
Expand Up @@ -32,6 +32,7 @@
# consuming CPU cycles. No disk I/O is performed since the ring buffer holds a
# fixed-size in-memory trace.

from __future__ import print_function
import sys
import os

Expand Down Expand Up @@ -77,8 +78,8 @@ def tail_trace():
pass

def usage():
print 'Usage: %s start [buffer_size_kb] | stop | dump | tail' % sys.argv[0]
print 'Control the KVM flight recorder tracing.'
print('Usage: %s start [buffer_size_kb] | stop | dump | tail' % sys.argv[0])
print('Control the KVM flight recorder tracing.')
sys.exit(0)

def main():
Expand All @@ -87,15 +88,15 @@ def main():

cmd = sys.argv[1]
if cmd == '--version':
print 'kvm_flightrecorder version 1.0'
print('kvm_flightrecorder version 1.0')
sys.exit(0)

if not os.path.isdir(tracing_dir):
print 'Unable to tracing debugfs directory, try:'
print 'mount -t debugfs none /sys/kernel/debug'
print('Unable to tracing debugfs directory, try:')
print('mount -t debugfs none /sys/kernel/debug')
sys.exit(1)
if not os.access(tracing_dir, os.W_OK):
print 'Unable to write to tracing debugfs directory, please run as root'
print('Unable to write to tracing debugfs directory, please run as root')
sys.exit(1)

if cmd == 'start':
Expand All @@ -105,16 +106,16 @@ def main():
try:
buffer_size_kb = int(sys.argv[2])
except ValueError:
print 'Invalid per-cpu trace buffer size in KB'
print('Invalid per-cpu trace buffer size in KB')
sys.exit(1)
write_file(trace_path('buffer_size_kb'), str(buffer_size_kb))
print 'Per-CPU ring buffer size set to %d KB' % buffer_size_kb
print('Per-CPU ring buffer size set to %d KB' % buffer_size_kb)

start_tracing()
print 'KVM flight recorder enabled'
print('KVM flight recorder enabled')
elif cmd == 'stop':
stop_tracing()
print 'KVM flight recorder disabled'
print('KVM flight recorder disabled')
elif cmd == 'dump':
dump_trace()
elif cmd == 'tail':
Expand Down
1 change: 1 addition & 0 deletions scripts/kvm/vmxcap
Expand Up @@ -10,6 +10,7 @@
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.

from __future__ import print_function
MSR_IA32_VMX_BASIC = 0x480
MSR_IA32_VMX_PINBASED_CTLS = 0x481
MSR_IA32_VMX_PROCBASED_CTLS = 0x482
Expand Down
1 change: 1 addition & 0 deletions scripts/qmp/qemu-ga-client
Expand Up @@ -36,6 +36,7 @@
# See also: https://wiki.qemu.org/Features/QAPI/GuestAgent
#

from __future__ import print_function
import base64
import random

Expand Down

0 comments on commit f03868b

Please sign in to comment.