Received: by 10.192.165.148 with SMTP id m20csp4785351imm; Tue, 8 May 2018 14:28:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqd+cZQ0acJ9qk5citkZfBpurR/E8H5jHbI944ktYbPC58pBLGgZBFfHJNi9V5oMNWD66Jl X-Received: by 2002:a63:6406:: with SMTP id y6-v6mr33949514pgb.205.1525814933079; Tue, 08 May 2018 14:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525814933; cv=none; d=google.com; s=arc-20160816; b=HOZcUO2CrwEZXukZSW4HvIo0Ba5r8MfJ4j7bM4DTJuyi6fImFPlAvw7rHCgX9ngqWe 33mRbSjxkLgdWt9yy1myMYw5dpWpzFLaZAeqYLH+UylX+o1EVElENkF9NZdDQ5Cjgn53 q1ADeKpyUJ0v++07qKX1jfR7LC98lyR59dEWtNIhCpgv2qCN0UCtpXw7K0rR5v5Ez8hJ XC0ro144hdJD2IrQrXyqOWLnGTUn5dEU6JqFlHTj84lLNVwnTqtGi+qKVYZTXwHBGFoH hIed9MOnyMrQOPGeF0k12YT7XJN54vHTspiqg0JseKpcr5I7Bi75zS6/76JKoimowsN0 RVfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature :arc-authentication-results; bh=ek0qvxgTHjOTFy+ouTLumjM4TkIl7e8Ur600pCoBzxM=; b=lZyD/3Td4xFk1zon3cav8CciJzQQt3d26cmpFRXlTgZTK/vCrlmlzi2TveU6pPfZE0 IbCSnwyLpuly1CECm20/iDMR4bx+zmfTWjRnAcvf3J14jaWC+uUOtEex5rrOWOmADsEY 1VSCu9ShFpC+VWKiNrhJmTE2Sw14iEe5Hxd1Eyiwt9Hupt3plssBahNoVwcrzrj3yct5 Hpn3opcahwgBLv2gLELF29joPY/x0yKRDqN4V8CQ8SI9B2qVHFITU6AMxdPx/KOPVSNe r2iJEPaoGDoo3Uu7Td0F3Yc1qfgSlT9Fn2TVuiQdCGWvdkkz70U+nbMcWDN1gMIKeW7b Br6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jcline.org header.s=rdybrs3533vx7mghocfwl3vdwgpl2v5u header.b=eUD4H/p7; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=SQdy2pHA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si25941911pff.159.2018.05.08.14.28.38; Tue, 08 May 2018 14:28:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@jcline.org header.s=rdybrs3533vx7mghocfwl3vdwgpl2v5u header.b=eUD4H/p7; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=SQdy2pHA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932344AbeEHV1y (ORCPT + 99 others); Tue, 8 May 2018 17:27:54 -0400 Received: from a8-126.smtp-out.amazonses.com ([54.240.8.126]:56886 "EHLO a8-126.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756018AbeEHV1t (ORCPT ); Tue, 8 May 2018 17:27:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=rdybrs3533vx7mghocfwl3vdwgpl2v5u; d=jcline.org; t=1525814868; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=ebnrNks+9wsItPdf6GwAs4vhbi57wx7/65L1VlYzq+M=; b=eUD4H/p7HL+1s6aNmnoGwz61LuUDUcnoDZfgUXgNHjvNGNVOB5fpkRkx4OfrCwmN UYT8SroRBJfmd+DzplnPfzF0kMrFH7gZhm2xcvir6QY8nWLgzqXlI0YiroUl4OE8dwM eTNvbe8e6fOB4EARgRdRKS77TBeHhrK8VW/z0oZU= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1525814868; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=ebnrNks+9wsItPdf6GwAs4vhbi57wx7/65L1VlYzq+M=; b=SQdy2pHAN3vAxO6Li6VI7k6xz/QF8mRvWMcThmyezfIza+NxAxgtHuEgvC1MhgEP OBIKbH3vbVu9KL/j2o1tzWKIao8Zsip+xEu+7lFzQwio34IWYDqjatZDPmn6euVrTT8 xwAZf7uDEG5WtMuwkLfs+3zCe+Yv0RCMeNImS1JY= X-Virus-Scanned: amavisd-new at jcline.org From: Jeremy Cline To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , "Herton R . Krzesinski" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Jeremy Cline Subject: [PATCH 6/8] perf scripts python: Add Python 3 support to sched-migration.py Date: Tue, 8 May 2018 21:27:47 +0000 Message-ID: <0100016341a737a5-44ec436f-3440-4cac-a03f-ddfa589bf308-000000@email.amazonses.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: X-SES-Outgoing: 2018.05.08-54.240.8.126 Feedback-ID: 1.us-east-1.z18Isoc/FaoPOvCyJyi1mnTt8STwoRuibXVNoUcvG6g=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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