Skip to content

Commit c45b168

Browse files
jeremyclineacmel
authored andcommitted
perf scripts python: Add Python 3 support to Util.py
Support both Python 2 and Python 3 in Util.py. The dict class no longer has a ``has_key`` method and print is now a function rather than a statement. This should have no functional change. Signed-off-by: Jeremy Cline <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Herton Krzesinski <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/0100016341a730c6-8db8b9b1-da2d-4ee3-96bf-47e0ae9796bd-000000@email.amazonses.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 2ab8926 commit c45b168

File tree

1 file changed

+6
-5
lines changed
  • tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace

1 file changed

+6
-5
lines changed

tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# This software may be distributed under the terms of the GNU General
66
# Public License ("GPL") version 2 as published by the Free Software
77
# Foundation.
8+
from __future__ import print_function
89

910
import errno, os
1011

@@ -33,7 +34,7 @@ def nsecs_str(nsecs):
3334
return str
3435

3536
def add_stats(dict, key, value):
36-
if not dict.has_key(key):
37+
if key not in dict:
3738
dict[key] = (value, value, value, 1)
3839
else:
3940
min, max, avg, count = dict[key]
@@ -72,10 +73,10 @@ def clear_term():
7273
except:
7374
if not audit_package_warned:
7475
audit_package_warned = True
75-
print "Install the audit-libs-python package to get syscall names.\n" \
76-
"For example:\n # apt-get install python-audit (Ubuntu)" \
77-
"\n # yum install audit-libs-python (Fedora)" \
78-
"\n etc.\n"
76+
print("Install the audit-libs-python package to get syscall names.\n"
77+
"For example:\n # apt-get install python-audit (Ubuntu)"
78+
"\n # yum install audit-libs-python (Fedora)"
79+
"\n etc.\n")
7980

8081
def syscall_name(id):
8182
try:

0 commit comments

Comments
 (0)