Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1733507 > unrolled thread
| Started by | Jeremy Cline <jeremy@jcline.org> |
|---|---|
| First post | 2017-09-17 19:50 +0200 |
| Last post | 2017-09-18 11:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] tools/kvm_stat: Add Python 3 support to kvm_stat Jeremy Cline <jeremy@jcline.org> - 2017-09-17 19:50 +0200
Re: [PATCH] tools/kvm_stat: Add Python 3 support to kvm_stat Stefan Hajnoczi <stefanha@gmail.com> - 2017-09-18 11:40 +0200
| From | Jeremy Cline <jeremy@jcline.org> |
|---|---|
| Date | 2017-09-17 19:50 +0200 |
| Subject | [PATCH] tools/kvm_stat: Add Python 3 support to kvm_stat |
| Message-ID | <uqLRD-2Eg-5@gated-at.bofh.it> |
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@jcline.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
[toc] | [next] | [standalone]
| From | Stefan Hajnoczi <stefanha@gmail.com> |
|---|---|
| Date | 2017-09-18 11:40 +0200 |
| Message-ID | <ur0GZ-4j6-1@gated-at.bofh.it> |
| In reply to | #1733507 |
On Sun, Sep 17, 2017 at 05:49:51PM +0000, Jeremy Cline wrote: > 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@jcline.org> > --- > tools/kvm/kvm_stat/kvm_stat | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web