Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5241790imb; Thu, 7 Mar 2019 10:52:31 -0800 (PST) X-Google-Smtp-Source: APXvYqwGISDLEgQF0LBgtD5zKe4wcKlV4/ErG6w+L9luwJSLpOp/Va+UNN57vlZT/Vx/wngu88aM X-Received: by 2002:a62:f51d:: with SMTP id n29mr14073808pfh.21.1551984751179; Thu, 07 Mar 2019 10:52:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551984751; cv=none; d=google.com; s=arc-20160816; b=XOVGdVZcMLS1NOuRauE07s99tAtM0saOwfZD5aV6bSjcpeXlE8kN03/LJmKV4mIkC/ uRqeyu5x/Poyid1j/SYe9SBM5hmIizOcoBbOmdJvLZ1EkUyYv5Wp0Gy4kPpdWPwrE1l6 zkb1CiahyBcldRPEVLHcfhySgC/eDUwXcrc3X0LzuPrDEkUJVOVY5+SZ1fAjy7/47TLh /0niFjrNVuihst0xPN4c72NqyTX8fpJDuKuZMze8fkGTnMKB/reYOyIc6PWv9XLMdwZK vcbR+wTp1hW3Pzw9ESyYi2dXbXFB3YXBc/ZmAc+jAD95HMWnG/cGB4+yLUs5sGc16a5x HphQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=x2omEGC/gv+4G7Hb+8y4ulQzfopNnalnjzivkJEZ9J8=; b=ElN6NCFNtKh31zcz5sCHiHhzF1IeF5mNvM+7e7io4mMPhCLbr8iSiwRA2AzcFWDdrx pM2n1FpcfklIfd1gdY0pTjLQzVlJlcDcWUwqUPfUzBozA+uXvGz1EW5Q2fiZLdkSefgh xXC/zgArVxTHCJnwWpJuIbYZf0uMjK6fuTqO7jKGHgTwBERC9ECSoVHpq6J1i6LikwzF pBWwyKq58t2T3sm/uBGwtsK7GYozsYPBTy3s6zu+Y737HBEcTBiEUyZ+KGzV0X5edZIt fMiAWo9eLboqwtP00KWhrPPxn1osAv2SnFc4wuQt0tQ9iBrX/pXHpxvBkjk1P54x9kOs 6NUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lOdOFX7r; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si4634126pfh.188.2019.03.07.10.52.15; Thu, 07 Mar 2019 10:52:31 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lOdOFX7r; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726298AbfCGSvu (ORCPT + 99 others); Thu, 7 Mar 2019 13:51:50 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:46902 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbfCGSvt (ORCPT ); Thu, 7 Mar 2019 13:51:49 -0500 Received: by mail-qk1-f195.google.com with SMTP id i5so9655381qkd.13; Thu, 07 Mar 2019 10:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=x2omEGC/gv+4G7Hb+8y4ulQzfopNnalnjzivkJEZ9J8=; b=lOdOFX7r7D6zehRSnghz1hrFo3wCCxSNPYDw5ocu0oWTbcT9uVk4mNhRJJwBEJ1bh7 c4kiXRMh4jPZmcIgg/x6sLyfFhnURhsbdYpybW/q0K9F0F5J5m+YZQmMaUfWgzjGo2aL k9+2YuuP/O5S9Yn2ox+5N4jWBYRhPa9/YY+9x6qggJYEjv8smkmeqMRrXzcj5ez4nmAk wLZKWGm35+iM2Ewl5GOMxp0L9ur4FEEZEUQyiffrhUqr3ZHGPlkHrfzshESCQ0UzhHsc /J5vUdME5VlycVPvVAuGoQooWjPKqOMFt73mlt4Q8v0pjJhl9wqHjHDeDSha5XRXlxI6 TsDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x2omEGC/gv+4G7Hb+8y4ulQzfopNnalnjzivkJEZ9J8=; b=Dzzvrt8h9kzLNrkPloS6aMHXSaPuNmgR8GUS/a3ADl10YKWu9DVSrIJQCoIxW/r7KY xWuozuX12u12dt0j1pvKE/tCuM89AgwExa3WKiIzU5ZVn9+Dc9l5meX2k2IZ2TdnVu7g cLZY/BTZdptK1KaFqyRigkR1kmrcYpFgQLH/HNKyu7jlCVAImvJQY7/jdjWdnvHJ5yki K7rsoGxKqiNQigKcHLRa7X1pBRS/QjOLWF5RggAWyBpToESTw2eKnJ5zHvGrMGZEi5Al A+KotMht0RYTbe9sBKwE53E+rOfvHkdYe/rLptFJKP+V0hnC1882On0zgbmzOcYkGT6p PW4w== X-Gm-Message-State: APjAAAWsCpP1fkRNqN1sATH28O7y3o8a1t4B/5R8/bl33tC887W/pOR3 iPnuuwMf5PedWqedmjAVMBc8Xq+6 X-Received: by 2002:a37:aa86:: with SMTP id t128mr10798849qke.205.1551984708091; Thu, 07 Mar 2019 10:51:48 -0800 (PST) Received: from quaco.ghostprotocols.net ([190.15.121.82]) by smtp.gmail.com with ESMTPSA id n78sm3131273qkn.10.2019.03.07.10.51.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:51:47 -0800 (PST) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CCD9D4039C; Thu, 7 Mar 2019 15:51:42 -0300 (-03) Date: Thu, 7 Mar 2019 15:51:42 -0300 To: Tony Jones Cc: Adrian Hunter , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Seeteena Thoufeek Subject: Re: [PATCH v2 6/7] perf script python: add Python3 support to sql scripts Message-ID: <20190307185142.GA32240@kernel.org> References: <20190302011903.2416-1-tonyj@suse.de> <20190302011903.2416-7-tonyj@suse.de> <7353b42e-ea14-e044-adfe-5a9705bf030c@intel.com> <72ea2e3d-1b82-549e-741f-d2b532e4c33b@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <72ea2e3d-1b82-549e-741f-d2b532e4c33b@suse.de> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Mar 06, 2019 at 08:32:42AM -0800, Tony Jones escreveu: > On 3/6/19 1:26 AM, Adrian Hunter wrote: > > On 2/03/19 3:19 AM, Tony Jones wrote: > >> Support both Python2 and Python3 in the exported-sql-viewer.py, > >> export-to-postgresql.py and export-to-sqlite.py scripts > >> > >> 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: Adrian Hunter > > > > Apart from one issue (see below), it looks good, thank you! > > > >> --- > >> tools/perf/scripts/python/export-to-postgresql.py | 65 +++++++++++++++-------- > >> tools/perf/scripts/python/export-to-sqlite.py | 23 ++++---- > >> tools/perf/scripts/python/exported-sql-viewer.py | 42 ++++++++++----- > >> 3 files changed, 84 insertions(+), 46 deletions(-) > >> > >> diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py > >> index 390a351d15ea..439bbbf1e036 100644 > >> --- a/tools/perf/scripts/python/export-to-postgresql.py > >> +++ b/tools/perf/scripts/python/export-to-postgresql.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 > >> @@ -199,6 +201,16 @@ import datetime > >> > >> from PySide.QtSql import * > >> > >> +if sys.version_info < (3, 0): > >> + def tobytes(str): > >> + return str > >> +else: > >> + def tobytes(str): > >> + # Use latin-1 (ISO-8859-1) so all code-points 0-255 will result > >> + # in one byte (note utf-8 is 2 bytes for values > 128 and > >> + # ascii is limited to values <= 128) > >> + return bytes(str, "ISO-8859-1") > > > > Probably this should be the server_encoding, but python2 allowed UTF-8 > > so let's just use UTF-8 for now. That will also mean doing the conversion > > before getting the len(), otherwise len() can be wrong. > > I'm not totally understanding what you're saying here. The rationale for > using latin-1 and not UTF-8 was clearly expressed in the comment. Else you > do indeed run into length issues. > > Would it be easier, since you have a) more familiarity with the code b) some > specific issues I'm not fully understanding if you just took this patch and > made the changes you want yourself. I doubt I'll ever use these scripta, my > interest is purely in eliminating Python2 as a fixed requirement. Adrian, can you please reply here? I'm not familiar with this tobytes() python2/python3 difference, what do you mean about using 'server_encoding'? Where is that defined? - Arnaldo