LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jeremy Cline <jeremy@jcline.org>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	"Herton R . Krzesinski" <herton@redhat.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jeremy Cline <jeremy@jcline.org>
Subject: [PATCH 6/8] perf scripts python: Add Python 3 support to sched-migration.py
Date: Tue, 8 May 2018 21:27:47 +0000	[thread overview]
Message-ID: <0100016341a737a5-44ec436f-3440-4cac-a03f-ddfa589bf308-000000@email.amazonses.com> (raw)
In-Reply-To: <cover.1525811971.git.jeremy@jcline.org>

Support both Python 2 and Python 3 in the sched-migration.py script.
This should have no functional change.

Signed-off-by: Jeremy Cline <jeremy@jcline.org>
---
 tools/perf/scripts/python/sched-migration.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/perf/scripts/python/sched-migration.py b/tools/perf/scripts/python/sched-migration.py
index de66cb3b72c9..3473e7f66081 100644
--- a/tools/perf/scripts/python/sched-migration.py
+++ b/tools/perf/scripts/python/sched-migration.py
@@ -9,13 +9,17 @@
 # This software is distributed under the terms of the GNU General
 # Public License ("GPL") version 2 as published by the Free Software
 # Foundation.
-
+from __future__ import print_function
 
 import os
 import sys
 
 from collections import defaultdict
-from UserList import UserList
+try:
+    from UserList import UserList
+except ImportError:
+    # Python 3: UserList moved to the collections package
+    from collections import UserList
 
 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
@@ -300,7 +304,7 @@ class TimeSliceList(UserList):
 		if i == -1:
 			return
 
-		for i in xrange(i, len(self.data)):
+		for i in range(i, len(self.data)):
 			timeslice = self.data[i]
 			if timeslice.start > end:
 				return
@@ -336,8 +340,8 @@ class SchedEventProxy:
 		on_cpu_task = self.current_tsk[headers.cpu]
 
 		if on_cpu_task != -1 and on_cpu_task != prev_pid:
-			print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \
-				(headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid)
+			print("Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \
+				headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid)
 
 		threads[prev_pid] = prev_comm
 		threads[next_pid] = next_comm
-- 
2.17.0

  parent reply	other threads:[~2018-05-08 21:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1525811971.git.jeremy@jcline.org>
2018-05-08 21:27 ` [PATCH 1/8] perf tools: Generate a Python script compatible with Python 2 and 3 Jeremy Cline
2018-07-12 13:57   ` [tip:perf/urgent] " tip-bot for Jeremy Cline
2018-05-08 21:27 ` [PATCH 3/8] perf scripts python: Add Python 3 support to SchedGui.py Jeremy Cline
2018-07-12 13:58   ` [tip:perf/urgent] " tip-bot for Jeremy Cline
2018-05-08 21:27 ` [PATCH 2/8] perf scripts python: Add Python 3 support to Core.py Jeremy Cline
2018-07-12 13:58   ` [tip:perf/urgent] " tip-bot for Jeremy Cline
2018-05-08 21:27 ` [PATCH 4/8] perf scripts python: Add Python 3 support to Util.py Jeremy Cline
2018-07-12 13:59   ` [tip:perf/urgent] " tip-bot for Jeremy Cline
2018-05-08 21:27 ` Jeremy Cline [this message]
2018-07-12 13:59   ` [tip:perf/urgent] perf scripts python: Add Python 3 support to sched-migration.py tip-bot for Jeremy Cline
2018-05-08 21:27 ` [PATCH 5/8] perf scripts python: Add Python 3 support to EventClass.py Jeremy Cline
2018-07-12 14:00   ` [tip:perf/urgent] " tip-bot for Jeremy Cline
2018-05-08 21:27 ` [PATCH 8/8] perf tests: Add Python 3 support to attr.py Jeremy Cline
2018-05-08 21:27 ` [PATCH 7/8] perf scripts python: Add Python 3 support to stat-cpi.py Jeremy Cline

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0100016341a737a5-44ec436f-3440-4cac-a03f-ddfa589bf308-000000@email.amazonses.com \
    --to=jeremy@jcline.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=herton@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --subject='Re: [PATCH 6/8] perf scripts python: Add Python 3 support to sched-migration.py' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).