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.
Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all
Unified · Split
| @@ -5,6 +5,7 @@ · 4 unmodified lines | |||
| 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. |
| 8 | from __future__ import print_function | ||
| 8 | 9 | ||
| 9 | import errno, os | 10 | import errno, os |
| 10 | 11 | ||
| @@ -33,7 +34,7 @@ def nsecs_str(nsecs): · 22 unmodified lines | |||
| 33 | return str | 34 | return str |
| 34 | 35 | ||
| 35 | def add_stats(dict, key, value): | 36 | def 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: · 32 unmodified lines | |||
| 72 | except: | 73 | except: |
| 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 | ||
| 80 | def syscall_name(id): | 81 | def syscall_name(id): |
| 81 | try: | 82 | try: |