Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4352538imb; Wed, 6 Mar 2019 11:14:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzZ/DUmbwWcvMx33Q2vG2B56U9rZFaxHpD/nt4cHXM2YkcwJi3X3sevIW3Hdv5qChoQor/1 X-Received: by 2002:aa7:885a:: with SMTP id k26mr8745802pfo.70.1551899681759; Wed, 06 Mar 2019 11:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551899681; cv=none; d=google.com; s=arc-20160816; b=yd0zURFVGKVggXJOJoaIBgleenhis4i6o9Ejgs+meuhHbjIeafIJR3Ma++yN2iBBsq 8nzJb4VtRAeuSzdpIFO62p5lVyatgtcYaqcY2yd5M0NgAEJWUoOQNVEo2gHTHMnbZLke g06E0NiOnaD9YYHlWbjDjvIbQjZngDfiODYRh/jXq5Prm9n7wOEL2i9rBonS6QZAoPpM vxfxLXiPt1cjaS/1eU1R3FIhyk21MXj/ciMTuIhI4G5wkTn/Sw9QD3eKC/ejcI3muz1J jXnErFfBXO//4ogcaNQtZOcz52hdC/Dn5/OyGuwLGa4Ddmo8tpf0LRVW1MHdjXVq8QRG lkCg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=fCNGFS196G67Vl7SSh2ZhReF6M8aCChC/I/WtjOUh9E=; b=n/rt8S/oPdGPh0h8TlJcjYbNnBHC81YYLvhoWTQyX/0kUsq8q3JYFFsIJiPRyE9ICq k+8GFpSKqoVNGNOWwtKI1L+QliDfYQHwyIjvp0GhsqF3ZzsJR0BJzGeNOHltdF5+lxk9 EMe4X+D1IVJn3hmwvTR3S/mBtm62tpcREM/wC+Tc0bYiPuxRtdEZR0TgurU2zjNeQ3Mv aEiReMhjIiqR4ls9dpNunjudohNuTSY2zfJqlpwHH30JgdAz76nr95XhAbR31Zj5IR8F spSzjJucRwvlGdbpttCBWhzGJYw8HHBpuqsrjWmhKvI9A+dcdaRMCzzDdzOgtAua5s7g CisA== 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 b1si2200701pld.351.2019.03.06.11.14.26; Wed, 06 Mar 2019 11:14:41 -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 S1729823AbfCFQct (ORCPT + 99 others); Wed, 6 Mar 2019 11:32:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:35522 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726127AbfCFQcs (ORCPT ); Wed, 6 Mar 2019 11:32:48 -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 8447ABDF1; Wed, 6 Mar 2019 16:32:46 +0000 (UTC) Subject: Re: [PATCH v2 6/7] perf script python: add Python3 support to sql scripts To: Adrian Hunter , linux-kernel@vger.kernel.org Cc: acme@kernel.org, linux-perf-users@vger.kernel.org, Seeteena Thoufeek References: <20190302011903.2416-1-tonyj@suse.de> <20190302011903.2416-7-tonyj@suse.de> <7353b42e-ea14-e044-adfe-5a9705bf030c@intel.com> From: Tony Jones Openpgp: preference=signencrypt Autocrypt: addr=tonyj@suse.de; prefer-encrypt=mutual; keydata= mQGiBE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KZ3wADBQf/b5cVNyb5i8QI0G7BPGBNn4VlQX5n66TsPBnrRNOi3MhTTVEBCp8s+jqUjJjX EjjA+O4hIm7Qqdsozurw7GlcQ0A06dIzO/1RUglZZMoC0JL43ZQmJ+3+yFrLjWgGH6ev6AOb YLH7ZujgAB5n0Hy2ZIChzsKLKbHptFtBvpDKB8updq+GunsY4oN3wGa67h9sHqDvjyp64Czg n8G5uGLwx3f/edbECKz5kPUSzChEk3suK742SEP01v4ra5WX88Hn81NjGByQMz9acJLdC7Ff LzXvbNa0KgvDaSllYfsJIoGCz3eKVOuTWXOiaEIKuy833+3mr2PulLCyLKysAEddKohJBBgR AgAJBQJJEJm8AhsMAAoJELFYWyEf4koXhgQAn1EGATLZPS53At9t+p3S8BkNI9yRAJ9A0OmL liv+rwEesYGlGeGNaKHTJw== Message-ID: <72ea2e3d-1b82-549e-741f-d2b532e4c33b@suse.de> Date: Wed, 6 Mar 2019 08:32:42 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <7353b42e-ea14-e044-adfe-5a9705bf030c@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Tony