History

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.

Jeremy Cline committed 8 years ago

Commit c45b1681 parent 2ab89261 file · +6 −5Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py+6−5
@@ -5,6 +5,7 @@ · 4 unmodified lines
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): · 22 unmodified lines
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 @@ try: · 32 unmodified lines
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:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t