Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6359717imb; Fri, 8 Mar 2019 16:05:52 -0800 (PST) X-Google-Smtp-Source: APXvYqw0t5kXcUN37wKWbiyQruzE/NITI2POxe/6W21czytL6RN0oHAWTm1UViXKidppgW51HbAA X-Received: by 2002:a65:5c07:: with SMTP id u7mr19459356pgr.320.1552089952912; Fri, 08 Mar 2019 16:05:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552089952; cv=none; d=google.com; s=arc-20160816; b=kNLw+KY7EsEc1JdzdpqwHCnrNJiuqLbSsXnQ1AFawyq0pEiv/Wn3PD7oSXEP8nh63S hj8E+0s4XWcDgWbM/tuAB5ztpB0OCW7YpJaqC33+Kdh76AVSjC39jtA+4BodC1xVdl6d lc2SaBJhOkKIs4t75Dn+bbxXA6XmrnjULlPsh1RfPZBPisc0D1BwZNZkBm9YyOA735vZ 3kWVERiiX+OX7g56FS0H1sC5tYodvy5ZXRWa3+iEZu5rGx0J8RZX8c1LMNjH7xvhTIXQ 1UKkwZdnfd6HB6EJGcV6CClL70IaGUzWN6mecN7wUfrb79ULUQEZSHYTT59COCmLLrUV Q+rw== 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=6B0mbGMcstn8mfv+9jr7bdL7bttOU/uiGyPTtA11Sxs=; b=bmX9+O0Dr0WNYBEQhnsBoVu9DNUmupI+f/XArCMc5lbCmsdpasDRlm9W5Npm/LRj1+ mC6gxNxRIls8mO7eWHTDKn3t9ArPsL86m0WGTOZx5MU0+YR1Fv2tpeqcQVQckGAmyPwI XZmcQxxezJ4dljOfnKbsotflapq7JUeEaE3kTxAiaFv7o5xECsg4XQB7eE8OK8ysHDgr 0l7A3PpA/i4Yh3XcaweuKwkXwyBKCLbW3fQhFjX5aPlJog6oB+YnQjm+586gYbcgEFOc xmJT8Q8gxIjNnyvlR/T6qf9IWCgsTdrn1iZc54KSxOI47IyUOGyHdt7cDb2UchZMoePO nZ3A== 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 s3si8609339plb.230.2019.03.08.16.05.37; Fri, 08 Mar 2019 16:05:52 -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 S1726714AbfCIAEK (ORCPT + 99 others); Fri, 8 Mar 2019 19:04:10 -0500 Received: from mx2.suse.de ([195.135.220.15]:56166 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726435AbfCIAEG (ORCPT ); Fri, 8 Mar 2019 19:04:06 -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 6DA6CAC61; Sat, 9 Mar 2019 00:04:04 +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 , Adrian Hunter Subject: [PATCH v3 3/4] perf script python: add Python3 support to export-to-sqlite.py Date: Fri, 8 Mar 2019 16:05:17 -0800 Message-Id: <20190309000518.2438-4-tonyj@suse.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190309000518.2438-1-tonyj@suse.de> References: <20190309000518.2438-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 export-to-sqlite.py script 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: Adrian Hunter --- tools/perf/scripts/python/export-to-sqlite.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py index eb63e6c7107f..3da338243aed 100644 --- a/tools/perf/scripts/python/export-to-sqlite.py +++ b/tools/perf/scripts/python/export-to-sqlite.py @@ -10,6 +10,8 @@ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. +from __future__ import print_function + import os import sys import struct @@ -60,11 +62,14 @@ perf_db_export_mode = True perf_db_export_calls = False perf_db_export_callchains = False +def printerr(*args, **keyword_args): + print(*args, file=sys.stderr, **keyword_args) + def usage(): - print >> sys.stderr, "Usage is: export-to-sqlite.py [] [] []" - print >> sys.stderr, "where: columns 'all' or 'branches'" - print >> sys.stderr, " calls 'calls' => create calls and call_paths table" - print >> sys.stderr, " callchains 'callchains' => create call_paths table" + printerr("Usage is: export-to-sqlite.py [] [] []"); + printerr("where: columns 'all' or 'branches'"); + printerr(" calls 'calls' => create calls and call_paths table"); + printerr(" callchains 'callchains' => create call_paths table"); raise Exception("Too few arguments") if (len(sys.argv) < 2): @@ -100,7 +105,7 @@ def do_query_(q): return raise Exception("Query failed: " + q.lastError().text()) -print datetime.datetime.today(), "Creating database..." +print(datetime.datetime.today(), "Creating database ...") db_exists = False try: @@ -378,7 +383,7 @@ if perf_db_export_calls: call_query.prepare("INSERT INTO calls VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") def trace_begin(): - print datetime.datetime.today(), "Writing records..." + print(datetime.datetime.today(), "Writing records...") do_query(query, 'BEGIN TRANSACTION') # id == 0 means unknown. It is easier to create records for them than replace the zeroes with NULLs evsel_table(0, "unknown") @@ -397,14 +402,14 @@ unhandled_count = 0 def trace_end(): do_query(query, 'END TRANSACTION') - print datetime.datetime.today(), "Adding indexes" + print(datetime.datetime.today(), "Adding indexes") if perf_db_export_calls: do_query(query, 'CREATE INDEX pcpid_idx ON calls (parent_call_path_id)') do_query(query, 'CREATE INDEX pid_idx ON calls (parent_id)') if (unhandled_count): - print datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events" - print datetime.datetime.today(), "Done" + print(datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events") + print(datetime.datetime.today(), "Done") def trace_unhandled(event_name, context, event_fields_dict): global unhandled_count -- 2.16.4