Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp1977827imc; Fri, 22 Feb 2019 15:07:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IZclLqtV4TcF45GYI44qdUmsfq3xl/gpeW5KmtdJoFBbBrcgQlHsHbMx+dXIm3g5fLJNBm+ X-Received: by 2002:a63:1960:: with SMTP id 32mr6187806pgz.171.1550876854876; Fri, 22 Feb 2019 15:07:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550876854; cv=none; d=google.com; s=arc-20160816; b=KAo3RUmU63/KWsrttvbsuScrO4HhOMklc83i3QXDRRfKycb+px1hE7XsOqlVJrjaWU 07gvqJ7+dc+BWWf5j/S+5S1ov/T4QUalE1lOKnNyBH1VIoQfOQRq9IkJc59o5f3oUGyI N/gTS9ww09C1ktp1QMZUxVY4RNm+VfCmw8aWPKGdR9SwTeX1/foQCoJd/3ldSf8NFkTQ RE9pSsWThpyHHj30DGX2IEQWHD+bo7ZrDO6XMDcaKK9S6leeWkTuAEcAsreXLYWCLt0L Av5W9ezrb5FCaLRb/nk/yIk7ohoerrmkUjrEW/pCCvnhZBBQKH+FYsXqNbg6/okFvlRq 8nEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CixShPCDMYQ/JiH9NOxnIRlve+g9OnM4Iu6XWxsDtOk=; b=VsIJ4g4qCVvBqADr2gynjIt2lvEUA5ir3lu16lzJVsCykgwK4bhijcroROKSjb/aTr kC2lhkuIYifHO9P+1fexrI1FES0bh4xFtMsuQuIyJOtXx6EetGvO9SR6FgadeMp6dvpZ 8CzZCar75BakuTSCV1NVR9TdhNkQ8/0sqPBK5SjVDW9BvYcSQqlMhjd+m61wa7macx25 oPR2E07avKAPDtwjc+fVUv5p+VlvfYMwYKOc+qsNDyszMi5Cy4oiPIf01yJY5mXLSWqK JXr4gOg9hb4xsML5FVvYIJa34Cf//3TBZJtiVIRZ/cj1MW2r/LHW4STCFVHvdhpgjnqi 85wQ== ARC-Authentication-Results: i=1; mx.google.com; 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 a129si2563236pfa.273.2019.02.22.15.07.19; Fri, 22 Feb 2019 15:07:34 -0800 (PST) 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; 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 S1727396AbfBVXGo (ORCPT + 99 others); Fri, 22 Feb 2019 18:06:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:52388 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725900AbfBVXGn (ORCPT ); Fri, 22 Feb 2019 18:06:43 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2D8B5B017; Fri, 22 Feb 2019 23:06:42 +0000 (UTC) From: Tony Jones To: linux-kernel@vger.kernel.org Cc: linux-perf-users@vger.kernel.org, acme@kernel.org, Tony Jones , Seeteena Thoufeek , Tom Zanussi Subject: [PATCH 04/15] perf script python: add Python3 support to failed-syscalls-by-pid.py Date: Fri, 22 Feb 2019 15:06:08 -0800 Message-Id: <20190222230619.17887-5-tonyj@suse.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222230619.17887-1-tonyj@suse.de> References: <20190222230619.17887-1-tonyj@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support both Python2 and Python3 in the failed-syscalls-by-pid.py script There may be differences in the ordering of output lines due to differences in dictionary ordering etc. However the format within lines should be unchanged. The use of 'from __future__' implies the minimum supported Python2 version is now v2.6 Signed-off-by: Tony Jones Signed-off-by: Seeteena Thoufeek Cc: Tom Zanussi --- .../scripts/python/failed-syscalls-by-pid.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/perf/scripts/python/failed-syscalls-by-pid.py b/tools/perf/scripts/python/failed-syscalls-by-pid.py index cafeff3d74db..3648e8b986ec 100644 --- a/tools/perf/scripts/python/failed-syscalls-by-pid.py +++ b/tools/perf/scripts/python/failed-syscalls-by-pid.py @@ -5,6 +5,8 @@ # Displays system-wide failed system call totals, broken down by pid. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. +from __future__ import print_function + import os import sys @@ -32,7 +34,7 @@ if len(sys.argv) > 1: syscalls = autodict() def trace_begin(): - print "Press control+C to stop and show the summary" + print("Press control+C to stop and show the summary") def trace_end(): print_error_totals() @@ -57,22 +59,21 @@ def syscalls__sys_exit(event_name, context, common_cpu, def print_error_totals(): if for_comm is not None: - print "\nsyscall errors for %s:\n\n" % (for_comm), + print("\nsyscall errors for %s:\n" % (for_comm)) else: - print "\nsyscall errors:\n\n", + print("\nsyscall errors:\n") - print "%-30s %10s\n" % ("comm [pid]", "count"), - print "%-30s %10s\n" % ("------------------------------", \ - "----------"), + print("%-30s %10s" % ("comm [pid]", "count")) + print("%-30s %10s" % ("------------------------------", "----------")) comm_keys = syscalls.keys() for comm in comm_keys: pid_keys = syscalls[comm].keys() for pid in pid_keys: - print "\n%s [%d]\n" % (comm, pid), + print("\n%s [%d]" % (comm, pid)) id_keys = syscalls[comm][pid].keys() for id in id_keys: - print " syscall: %-16s\n" % syscall_name(id), + print(" syscall: %-16s" % syscall_name(id)) ret_keys = syscalls[comm][pid][id].keys() - for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True): - print " err = %-20s %10d\n" % (strerror(ret), val), + for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True): + print(" err = %-20s %10d" % (strerror(ret), val)) -- 2.20.1