Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3747134imu; Fri, 18 Jan 2019 16:46:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Ht7vug8c4KqROH2yT+rMoFRL+MExRxms8fzgGmaMMZV7WLkbCbXVCwpqnlZjYNn/cJZP3 X-Received: by 2002:a17:902:780c:: with SMTP id p12mr20712540pll.197.1547858808400; Fri, 18 Jan 2019 16:46:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547858808; cv=none; d=google.com; s=arc-20160816; b=MGwHDMtZc/bxo7Ppjarm9+LVrpbnQWVWRxIDbKWe7bec19c0vt5iGyVSR9BooHBk/K k7cTIPA8ZilVjsJKKrWCYiN9W98eurpsyprNtBKY96kc5IfImz0wP18OUEa27Z7p+MHP 5h7v5apxbd2VrBy5qhio2WVruzZFBxUWd/LbYDeIm+tLE4S6iMAI5s0We0eONGO9wNei asQP8I+67p7Zt5j9rkrmG9nlmBvG8l/Fn1rTTnJs+XhRINU7AAIeOxDPSJJFgYJb4+98 U9GDBXfNS4yQ1DNWHZ+MWcoXjhXiQsRd3N42coxjuwX1c16pmVH/ej7i/OgPPUrKhPnd HX/w== 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:to:subject; bh=ldOwHuVFmMkkjymVWwZ/9I2w2agRdvq9+C5tucppUnU=; b=RY7Nfth2/YP7i52oW9LbQAC2G/FrIo8zKeRw1JEU0TOAxmQvhwmW56YtUlifhHoEZB 5Nxv9ObFsfHRM+7UDPDOIpwCSyS0kdNmeO9fg5g+k/lI2ZWyJyKutuTUGpeV7IvhmhCe n6IvCrbrPl5gvfPLuZn5RtixOnC0BvNnd8kFthHI9m86UryMFwyJEuc+nGkXJM3pWMjH otrQMjxQbEYVoEYE7mvRdqz0kRVVxeFZrZSZkZn4LbzRyttMNN4dVnOef4byyhz2UWvL xltZ+Px/SA7cQUJw9jZkP1ODO7XqU53GTeZBTNZ/XkCT/XAbDY9IgT0Is4q9J0RvZl7+ nvKw== 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 v189si4869662pgb.398.2019.01.18.16.46.30; Fri, 18 Jan 2019 16:46:48 -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 S1726418AbfASApK (ORCPT + 99 others); Fri, 18 Jan 2019 19:45:10 -0500 Received: from mx2.suse.de ([195.135.220.15]:35086 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726033AbfASApJ (ORCPT ); Fri, 18 Jan 2019 19:45:09 -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 CDE88AD8E; Sat, 19 Jan 2019 00:45:07 +0000 (UTC) Subject: Re: [PATCH v2] perf scripts python: Add Python 3 support to exported-sql-viewer.py To: Seeteena Thoufeek , 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: Tony Jones Openpgp: preference=signencrypt Autocrypt: addr=tony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7saDicSFO2KcZvMbvDMqtPFipdF5UWo fZKZ3wADBQf/b5cVNyb5i8QI0G7BPGBNn4VlQX5n66TsPBnrRNOi3MhTTVEBCp8s+jqUjJjX EjjA+O4hIm7Qqdsozurw7GlcQ0A06dIzO/1RUglZZMoC0JL43ZQmJ+3+yFrLjWgGH6ev6AOb YLH7ZujgAB5n0Hy2ZIChzsKLKbHptFtBvpDKB8updq+GunsY4oN3wGa67h9sHqDvjyp64Czg n8G5uGLwx3f/edbECKz5kPUSzChEk3suK742SEP01v4ra5WX88Hn81NjGByQMz9acJLdC7Ff LzXvbNa0KgvDaSllYfsJIoGCz3eKVOuTWXOiaEIKuy833+3mr2PulLCyLKysAEddKohJBBgR AgAJBQJJEJm8AhsMAAoJELFYWyEf4koXhgQAn1EGATLZPS53At9t+p3S8BkNI9yRAJ9A0OmL liv+rwEesYGlGeGNaKHTJw== Message-ID: Date: Fri, 18 Jan 2019 16:45:04 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <1547718344-27382-3-git-send-email-s1seetee@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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" 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: