[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <0100015e90f5f216-374488c9-c5cb-43e9-825e-15f006b79825-000000@email.amazonses.com>
Date: Sun, 17 Sep 2017 17:49:51 +0000
From: Jeremy Cline <jeremy@...ine.org>
To: Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Jeremy Cline <jeremy@...ine.org>
Subject: [PATCH] tools/kvm_stat: Add Python 3 support to kvm_stat
Make kvm_stat support Python 3 by changing the use of "print" to a
function rather than a statement and switching from "iteritems" (removed
in Python 3) to "items".
With this change, kvm_stat is usable with Python 2.6 and greater.
Signed-off-by: Jeremy Cline <jeremy@...ine.org>
---
tools/kvm/kvm_stat/kvm_stat | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 32283d88701a..1ed18b3e619c 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -19,6 +19,7 @@ Three different ways of output formatting are available:
The data is sampled from the KVM's debugfs entries and its perf events.
"""
+from __future__ import print_function
import curses
import sys
@@ -666,7 +667,7 @@ class TracepointProvider(Provider):
"""Returns 'event name: current value' for all enabled events."""
ret = defaultdict(int)
for group in self.group_leaders:
- for name, val in group.read().iteritems():
+ for name, val in group.read().items():
if name in self._fields:
ret[name] += val
return ret
@@ -1369,7 +1370,7 @@ def batch(stats):
s = stats.get()
for key in sorted(s.keys()):
values = s[key]
- print '%-42s%10d%10d' % (key, values[0], values[1])
+ print('%-42s%10d%10d' % (key, values[0], values[1]))
except KeyboardInterrupt:
pass
@@ -1380,14 +1381,14 @@ def log(stats):
def banner():
for k in keys:
- print '%s' % k,
- print
+ print(k)
+ print()
def statline():
s = stats.get()
for k in keys:
- print ' %9d' % s[k][1],
- print
+ print(' %9d' % s[k][1])
+ print()
line = 0
banner_repeat = 20
while True:
--
2.13.5
Powered by blists - more mailing lists