aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorJeremy Cline <jeremy@jcline.org>2018-05-08 17:27:46 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-07-11 09:01:50 -0400
commitc45b168effb12719f6dfc8d2c20ba8c057e8c16b (patch)
treedb0433366c22c6d60b5c8b6200705fedfefaaf67 /tools/perf/scripts/python
parent2ab89262ff8895b8476b97345507c676fe3081fa (diff)
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 <jeremy@jcline.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Herton Krzesinski <herton@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/0100016341a730c6-8db8b9b1-da2d-4ee3-96bf-47e0ae9796bd-000000@email.amazonses.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python')
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
index f6c84966e4f8..7384dcb628c4 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
+++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
@@ -5,6 +5,7 @@
5# This software may be distributed under the terms of the GNU General 5# This software may be distributed under the terms of the GNU General
6# Public License ("GPL") version 2 as published by the Free Software 6# Public License ("GPL") version 2 as published by the Free Software
7# Foundation. 7# Foundation.
8from __future__ import print_function
8 9
9import errno, os 10import errno, os
10 11
@@ -33,7 +34,7 @@ def nsecs_str(nsecs):
33 return str 34 return str
34 35
35def add_stats(dict, key, value): 36def add_stats(dict, key, value):
36 if not dict.has_key(key): 37 if key not in dict:
37 dict[key] = (value, value, value, 1) 38 dict[key] = (value, value, value, 1)
38 else: 39 else:
39 min, max, avg, count = dict[key] 40 min, max, avg, count = dict[key]
@@ -72,10 +73,10 @@ try:
72except: 73except:
73 if not audit_package_warned: 74 if not audit_package_warned:
74 audit_package_warned = True 75 audit_package_warned = True
75 print "Install the audit-libs-python package to get syscall names.\n" \ 76 print("Install the audit-libs-python package to get syscall names.\n"
76 "For example:\n # apt-get install python-audit (Ubuntu)" \ 77 "For example:\n # apt-get install python-audit (Ubuntu)"
77 "\n # yum install audit-libs-python (Fedora)" \ 78 "\n # yum install audit-libs-python (Fedora)"
78 "\n etc.\n" 79 "\n etc.\n")
79 80
80def syscall_name(id): 81def syscall_name(id):
81 try: 82 try: