Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6070991imu; Mon, 21 Jan 2019 02:40:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN7LpKKHWAyTrGT+lzcNW16f9OY0ULE+3KcaUTDLFha8LNB+i40DT4kdhWTch0FCjcvydvpW X-Received: by 2002:a65:4784:: with SMTP id e4mr27126083pgs.12.1548067250375; Mon, 21 Jan 2019 02:40:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548067250; cv=none; d=google.com; s=arc-20160816; b=tRzKpt+3248vVvwz6AJTL/JI97RjZ8H2WmLqNDda7iDCf8ufEkUvxhAbt3pMGAMwmj NFW50zPX7KkdM0AOzyDkp80Oja8rRV3BpmGrXCCgAMSGKVupyck7UtHxXeMaok41Fsd8 VwBppxccFSHihpyMI7Y/Tcgg1mC/RZ60LEssv5+vetGgSRBHMMbNTt9Kn8nHN2msdITL 70N12QhXag0apVeR6tMYS1lzQCK5sNbpwrKlFDvtY4tjahYGC2nIJcRFlnqg55nsbCig mVCAndd/bGBIxEvs0aarmeVZEX1PoEW2E94LGEOKOWdgOd/2yaTeuZysZN8CWVbTG6aA SYng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=etxuuiKDY4Yos45CvnuVcV9puzOfSngEg/1NRrfoukk=; b=EbtLqqruWLQjJJA7surYtZWx9ldrKSXwP0NbH35y/MRrnBSugPRX1jWUUNFLRmFbEl I6Gx79W/+vgiObwsMlPSgpn7D+KDpt8t+VoxrbIRgj/WZdvhlRVw/w6JQ3zFc0F0xAOv BcIUrFjwEaOXY5mHJVdoGEJGvIhqw7At4V8xLsPJDGJhrbzUUDHKUc+f5e6ECbha8V9X ZpfZefHKWUXBufXvnrt16jpnxfO41fXl+jSt4GjyP+iW4YenRv5NEjq2OI2SyBkaVVw/ zbTSnWIelH10EP/9ayNz3T4C6nYCg4Y/zM9p/8q6l2X4gF2NFcwHG3GccDD/bSWB5X5z elaA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si233370pgn.325.2019.01.21.02.40.34; Mon, 21 Jan 2019 02:40:50 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbfAUKj2 (ORCPT + 99 others); Mon, 21 Jan 2019 05:39:28 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58250 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbfAUKj2 (ORCPT ); Mon, 21 Jan 2019 05:39:28 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0LActjm090559 for ; Mon, 21 Jan 2019 05:39:27 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2q5bnxtm8j-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 21 Jan 2019 05:39:27 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Jan 2019 10:39:25 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 21 Jan 2019 10:39:22 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0LAdLp850528356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 21 Jan 2019 10:39:21 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 08EA55204E; Mon, 21 Jan 2019 10:39:21 +0000 (GMT) Received: from oc1548405160.ibm.com (unknown [9.124.31.87]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 495B352054; Mon, 21 Jan 2019 10:39:19 +0000 (GMT) From: Seeteena Thoufeek To: tonyj@suse.de, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, ravi.bangoria@linux.ibm.com Cc: s1seetee@linux.vnet.ibm.com Subject: [PATCH v3] perf scripts python: Add Python 3 support to export-to-sqlite.py Date: Mon, 21 Jan 2019 16:09:17 +0530 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 x-cbid: 19012110-0020-0000-0000-0000030940E5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19012110-0021-0000-0000-0000215A6F4D Message-Id: <1548067157-10395-1-git-send-email-s1seetee@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-21_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901210085 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 export-to-sqlite.py. ``print`` is now a function rather than a statement. This should have no functional change. Also, handles the conversion of "print >> sys.stderr". Signed-off-by: Seeteena Thoufeek Reviewed-by: Ravi Bangoria --- tools/perf/scripts/python/export-to-sqlite.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py index 245caf2..95bfcb2 100644 --- a/tools/perf/scripts/python/export-to-sqlite.py +++ b/tools/perf/scripts/python/export-to-sqlite.py @@ -9,6 +9,7 @@ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. +from __future__ import print_function import os import sys @@ -61,10 +62,10 @@ perf_db_export_calls = False perf_db_export_callchains = False 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" + sys.stderr.write("Usage is: export-to-sqlite.py [] [] []"); + sys.stderr.write("where: columns 'all' or 'branches'"); + sys.stderr.write(" calls 'calls' => create calls and call_paths table"); + sys.stderr.write(" callchains 'callchains' => create call_paths table"); raise Exception("Too few arguments") if (len(sys.argv) < 2): @@ -100,7 +101,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: @@ -376,7 +377,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") @@ -394,13 +395,13 @@ 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)') 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 -- 1.8.3.1