Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6075912imu; Mon, 21 Jan 2019 02:47:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Blg2sQoP/117o7v7dfTwd0a/vMFMOqJBn9Pmlf3sWR4EdD/xsMvy27ezDlT6SGB0TfkzE X-Received: by 2002:aa7:868f:: with SMTP id d15mr28974519pfo.225.1548067627755; Mon, 21 Jan 2019 02:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548067627; cv=none; d=google.com; s=arc-20160816; b=r2oRctU6uUBRzCZhLtAhPWznXdINFBwmXXLjhtLIz2eUe+bvjndl3NRaZXoWUnlt40 6fqGBcbvDOWALobGZAstzfmFBCGI+V7sbQ+RdnVgcIT5G5En2ES2jh7lWu+4T+t9+elv IEyXxVDngFtcDHWZ2a758exIn1g2mPGxQRHNdN2WFRMgf2MXrH6BZFnUbsga0doy4aTU v7Mr6yDW+2xL9bd2k+DGpenerdmF7h6jowOMLnlaG/M76qUMD5MxaYkJe5/7oSsDJk53 SbWTwuKAL8tN1jjUKSS0CMIbaXbpyow4XWXa6LjiYeQMMteW7tde/Yyc4gvgfAMZd2WV OTNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:to:subject; bh=JYjkxl1dczR8hdNjE+JP5/D92p7U4iS/gHUztfvT3PI=; b=qqi1HEZUvLIacjgC2JuI7ajItYjowAsHqTmak2pVnL01LNZixR7ZJjsZnK04Tmnuqj kwVfLPKTJkBSYFWMx5B4yxYSqnRPpho/BLR5XYDp7oroyZ66rk1GMo+XbAh4mEcE60aR 0oZPzqS6XgyUFRZhL15deZxUiWn9iI6APWG7X4wt/NoFk6YPY2Tg/RzxRVwOuhz0m1a4 +c7nRYW6B6WwkRgVCzXdvh2XL2xR2GBpeiErUOMgEh6hC3vBMvADeCNF5LyBoNJn5dMo NJQTf4PcD9ojSvSxN6mp9rvRhjQMTM7cNblNci+aUqVhrBEBr2Urr4RGPrc5usAfoAMY yxIQ== 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 f82si12385206pfa.221.2019.01.21.02.46.52; Mon, 21 Jan 2019 02:47:07 -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 S1727444AbfAUKpv (ORCPT + 99 others); Mon, 21 Jan 2019 05:45:51 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44902 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726670AbfAUKpu (ORCPT ); Mon, 21 Jan 2019 05:45:50 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0LAhVOd053635 for ; Mon, 21 Jan 2019 05:45:49 -0500 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2q5chm86fj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 21 Jan 2019 05:45:49 -0500 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Jan 2019 10:45:48 -0000 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e35.co.us.ibm.com (192.168.1.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:45:44 -0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0LAjhQQ12386534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 21 Jan 2019 10:45:43 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAFD96A057; Mon, 21 Jan 2019 10:45:43 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27E3F6A05A; Mon, 21 Jan 2019 10:45:41 +0000 (GMT) Received: from oc1548405160.ibm.com (unknown [9.124.31.87]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 21 Jan 2019 10:45:40 +0000 (GMT) Subject: Re: [PATCH v2] perf scripts python: Add Python 3 support to exported-sql-viewer.py To: Tony Jones , 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 References: <1547718344-27382-1-git-send-email-s1seetee@linux.vnet.ibm.com> <1547718344-27382-3-git-send-email-s1seetee@linux.vnet.ibm.com> From: seeteena Date: Mon, 21 Jan 2019 16:15:39 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 19012110-0012-0000-0000-000016FDE72D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010445; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000275; SDB=6.01149620; UDB=6.00599033; IPR=6.00929945; MB=3.00025220; MTD=3.00000008; XFM=3.00000015; UTC=2019-01-21 10:45:47 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19012110-0013-0000-0000-000055E74FFB Message-Id: <4ce6c071-231e-7682-609e-dfc1d1d1e305@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-1901210086 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/19/2019 06:15 AM, Tony Jones wrote: > On 1/17/19 1:45 AM, Seeteena Thoufeek wrote: > >> +if sys.version_info[0] < 3: >> + import cPickle >> +else: >> + import _pickle as cPickle > Do you really need this? > > pickle is already in Python2. > > Also, did you test these changes on Python3? > > I think you'll find you also need the following hunk otherwise you're running into Unicode diffs on Py3. > > @@ -2590,8 +2590,8 @@ def Main(): > > is_sqlite3 = False > try: > - f = open(dbname) > - if f.read(15) == "SQLite format 3": > + f = open(dbname, "rb") > + if f.read(15) == b'SQLite format 3': > is_sqlite3 = True > f.close() > except: > > Plus you need to handle the conversion of "print >> sys.stderr" Thanks Tony. added changes to handle the conversion of "print >> sys.stderr" in export-to-postgresql.py and export-to-sqlite.py file as well.  revised patch posted. > > Attached is my version (against tip): > > --- a/tools/perf/scripts/python/exported-sql-viewer.py > +++ b/tools/perf/scripts/python/exported-sql-viewer.py > @@ -91,7 +91,7 @@ import sys > import weakref > import threading > import string > -import cPickle > +import pickle > import re > import os > from PySide.QtCore import * > @@ -1559,7 +1559,7 @@ class SQLTableDialogDataItem(): > return str(lower_id) > > def ConvertRelativeTime(self, val): > - print "val ", val > + print("val ", val) > mult = 1 > suffix = val[-2:] > if suffix == "ms": > @@ -1581,29 +1581,29 @@ class SQLTableDialogDataItem(): > return str(val) > > def ConvertTimeRange(self, vrange): > - print "vrange ", vrange > + print("vrange ", vrange) > if vrange[0] == "": > vrange[0] = str(self.first_time) > if vrange[1] == "": > vrange[1] = str(self.last_time) > vrange[0] = self.ConvertRelativeTime(vrange[0]) > vrange[1] = self.ConvertRelativeTime(vrange[1]) > - print "vrange2 ", vrange > + print("vrange2 ", vrange) > if not self.IsNumber(vrange[0]) or not self.IsNumber(vrange[1]): > return False > - print "ok1" > + print("ok1") > beg_range = max(int(vrange[0]), self.first_time) > end_range = min(int(vrange[1]), self.last_time) > if beg_range > self.last_time or end_range < self.first_time: > return False > - print "ok2" > + print("ok2") > vrange[0] = self.BinarySearchTime(0, self.last_id, beg_range, True) > vrange[1] = self.BinarySearchTime(1, self.last_id + 1, end_range, False) > - print "vrange3 ", vrange > + print("vrange3 ", vrange) > return True > > def AddTimeRange(self, value, ranges): > - print "value ", value > + print("value ", value) > n = value.count("-") > if n == 1: > pass > @@ -2577,7 +2577,7 @@ class DBRef(): > > def Main(): > if (len(sys.argv) < 2): > - print >> sys.stderr, "Usage is: exported-sql-viewer.py { | --help-only}" > + sys.stderr.write("Usage is: exported-sql-viewer.py { | --help-only}\n"); > raise Exception("Too few arguments") > > dbname = sys.argv[1] > @@ -2590,8 +2590,8 @@ def Main(): > > is_sqlite3 = False > try: > - f = open(dbname) > - if f.read(15) == "SQLite format 3": > + f = open(dbname, "rb") > + if f.read(15) == b'SQLite format 3': > is_sqlite3 = True > f.close() > except: > > > > >