* [PATCH] trace-cmd: python: Apply 2to3 print transformation to python files
@ 2019-05-03 16:15 John Kacur
2019-05-03 16:25 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: John Kacur @ 2019-05-03 16:15 UTC (permalink / raw)
To: linux-trace-devel; +Cc: Clark Williams, Steven Rostedt, John Kacur
In preperation for the python plugin to work with python3,
apply the 2to3 print transformation on the python files.
In python3 print is a function so needs to be bracketted.
This is safe to do because the syntax is compatible with python2 as well
Signed-off-by: John Kacur <jkacur@redhat.com>
---
python/event-viewer.py | 14 +++++++-------
python/tracecmd.py | 6 +++---
python/tracecmdgui.py | 12 ++++++------
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/python/event-viewer.py b/python/event-viewer.py
index c7c50d16df14..e3b2edd49491 100755
--- a/python/event-viewer.py
+++ b/python/event-viewer.py
@@ -23,7 +23,7 @@ def timing(func):
start = time.time()
ret = func(*arg)
end = time.time()
- print '@%s took %0.3f s' % (func.func_name, (end-start))
+ print('@%s took %0.3f s' % (func.func_name, (end-start)))
return ret
return wrapper
@@ -63,7 +63,7 @@ class EventStore(gtk.GenericTreeModel):
@timing
def _load_trace(self):
- print "Building trace index..."
+ print("Building trace index...")
index = 0
for cpu in range(0, trace.cpus):
rec = tracecmd_read_data(self.trace._handle, cpu)
@@ -73,7 +73,7 @@ class EventStore(gtk.GenericTreeModel):
self.refs.append(self.EventRef(index, ts, offset, cpu))
index = index + 1
rec = tracecmd_read_data(self.trace._handle, cpu)
- print "Loaded %d events from trace" % (index)
+ print("Loaded %d events from trace" % (index))
@timing
def _sort(self):
@@ -217,7 +217,7 @@ class EventView(gtk.TreeView):
elif data == "comm":
cell.set_property("markup", ev.comm)
else:
- print "Unknown Column:", data
+ print("Unknown Column:", data)
return False
return True
@@ -264,9 +264,9 @@ if __name__ == "__main__":
else:
filename = "trace.dat"
- print "Initializing trace..."
+ print("Initializing trace...")
trace = Trace(filename)
- print "Initializing app..."
+ print("Initializing app...")
app = EventViewerApp(trace)
- print "Go!"
+ print("Go!")
gtk.main()
diff --git a/python/tracecmd.py b/python/tracecmd.py
index 677c0f2ff6c3..4d481576b9f9 100644
--- a/python/tracecmd.py
+++ b/python/tracecmd.py
@@ -242,13 +242,13 @@ class Trace(object):
# Basic builtin test, execute module directly
if __name__ == "__main__":
t = Trace("trace.dat")
- print "Trace contains data for %d cpus" % (t.cpus)
+ print("Trace contains data for %d cpus" % (t.cpus))
for cpu in range(0, t.cpus):
- print "CPU %d" % (cpu)
+ print("CPU %d" % (cpu))
ev = t.read_event(cpu)
while ev:
- print "\t%s" % (ev)
+ print("\t%s" % (ev))
ev = t.read_event(cpu)
diff --git a/python/tracecmdgui.py b/python/tracecmdgui.py
index 3a9f8a530414..01bfd614f1cd 100644
--- a/python/tracecmdgui.py
+++ b/python/tracecmdgui.py
@@ -48,7 +48,7 @@ def timing(func):
start = time.time()
ret = func(*arg)
end = time.time()
- print '@%s took %0.3f s' % (func.func_name, (end-start))
+ print('@%s took %0.3f s' % (func.func_name, (end-start)))
return ret
return wrapper
@@ -62,7 +62,7 @@ class EventStore(gtk.GenericTreeModel):
self.cstore = trace_view_store_new(trace.handle)
self.gtk_cstore = trace_view_store_as_gtk_tree_model(self.cstore)
num_rows = trace_view_store_num_rows_get(self.cstore)
- print "Loaded %d events from trace" % (num_rows)
+ print("Loaded %d events from trace" % (num_rows))
def on_get_flags(self):
return trace_view_store_get_flags(self.gtk_cstore)
@@ -196,7 +196,7 @@ class EventView(gtk.TreeView):
elif data == "comm":
cell.set_property("markup", ev.comm)
else:
- print "Unknown Column:", data
+ print("Unknown Column:", data)
return False
return True
@@ -231,9 +231,9 @@ if __name__ == "__main__":
else:
filename = "trace.dat"
- print "Initializing trace..."
+ print("Initializing trace...")
trace = Trace(filename)
- print "Initializing app..."
+ print("Initializing app...")
app = EventViewerApp(trace)
- print "Go!"
+ print("Go!")
gtk.main()
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] trace-cmd: python: Apply 2to3 print transformation to python files
2019-05-03 16:15 [PATCH] trace-cmd: python: Apply 2to3 print transformation to python files John Kacur
@ 2019-05-03 16:25 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2019-05-03 16:25 UTC (permalink / raw)
To: John Kacur; +Cc: linux-trace-devel, Clark Williams
On Fri, 3 May 2019 18:15:41 +0200
John Kacur <jkacur@redhat.com> wrote:
> In preperation for the python plugin to work with python3,
> apply the 2to3 print transformation on the python files.
>
> In python3 print is a function so needs to be bracketted.
> This is safe to do because the syntax is compatible with python2 as well
>
> Signed-off-by: John Kacur <jkacur@redhat.com>
> ---
> python/event-viewer.py | 14 +++++++-------
> python/tracecmd.py | 6 +++---
> python/tracecmdgui.py | 12 ++++++------
> 3 files changed, 16 insertions(+), 16 deletions(-)
Allied. Thanks John!
-- Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-03 16:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-03 16:15 [PATCH] trace-cmd: python: Apply 2to3 print transformation to python files John Kacur
2019-05-03 16:25 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).