linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes
@ 2021-05-21  9:20 Adrian Hunter
  2021-05-21  9:20 ` [PATCH 1/3] perf scripts python: exported-sql-viewer.py: Fix copy to clipboard from Top Calls by elapsed Time report Adrian Hunter
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Adrian Hunter @ 2021-05-21  9:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa; +Cc: linux-kernel

Hi

Here are 3 minor fixes for stable.


Adrian Hunter (3):
      perf scripts python: exported-sql-viewer.py: Fix copy to clipboard from Top Calls by elapsed Time report
      perf scripts python: exported-sql-viewer.py: Fix Array TypeError
      perf scripts python: exported-sql-viewer.py: Fix warning display

 tools/perf/scripts/python/exported-sql-viewer.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)


Regards
Adrian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] perf scripts python: exported-sql-viewer.py: Fix copy to clipboard from Top Calls by elapsed Time report
  2021-05-21  9:20 [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes Adrian Hunter
@ 2021-05-21  9:20 ` Adrian Hunter
  2021-05-21  9:20 ` [PATCH 2/3] perf scripts python: exported-sql-viewer.py: Fix Array TypeError Adrian Hunter
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Adrian Hunter @ 2021-05-21  9:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa; +Cc: linux-kernel

Provide missing argument to prevent following error when copying a
selection to the clipboard:

Traceback (most recent call last):
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 4041, in <lambda>
    menu.addAction(CreateAction("&Copy selection", "Copy to clipboard", lambda: CopyCellsToClipboardHdr(self.view), self.view))
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 4021, in CopyCellsToClipboardHdr
    CopyCellsToClipboard(view, False, True)
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 4018, in CopyCellsToClipboard
    view.CopyCellsToClipboard(view, as_csv, with_hdr)
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 3871, in CopyTableCellsToClipboard
    val = model.headerData(col, Qt.Horizontal)
TypeError: headerData() missing 1 required positional argument: 'role'

Fixes: 96c43b9a7ab3b ("perf scripts python: exported-sql-viewer.py: Add copy to clipboard")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org
---
 tools/perf/scripts/python/exported-sql-viewer.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 7daa8bb70a5a..b5078d65704e 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -3868,7 +3868,7 @@ def CopyTableCellsToClipboard(view, as_csv=False, with_hdr=False):
 	if with_hdr:
 		model = indexes[0].model()
 		for col in range(min_col, max_col + 1):
-			val = model.headerData(col, Qt.Horizontal)
+			val = model.headerData(col, Qt.Horizontal, Qt.DisplayRole)
 			if as_csv:
 				text += sep + ToCSValue(val)
 				sep = ","
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] perf scripts python: exported-sql-viewer.py: Fix Array TypeError
  2021-05-21  9:20 [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes Adrian Hunter
  2021-05-21  9:20 ` [PATCH 1/3] perf scripts python: exported-sql-viewer.py: Fix copy to clipboard from Top Calls by elapsed Time report Adrian Hunter
@ 2021-05-21  9:20 ` Adrian Hunter
  2021-05-21  9:20 ` [PATCH 3/3] perf scripts python: exported-sql-viewer.py: Fix warning display Adrian Hunter
  2021-05-21 19:31 ` [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes Arnaldo Carvalho de Melo
  3 siblings, 0 replies; 5+ messages in thread
From: Adrian Hunter @ 2021-05-21  9:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa; +Cc: linux-kernel

The 'Array' class is present in more than one python standard library.
In some versions of Python 3, the following error occurs:

Traceback (most recent call last):
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 4702, in <lambda>
    reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewBranchView(x), self))
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 4727, in NewBranchView
    BranchWindow(self.glb, event_id, ReportVars(), self)
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 3208, in __init__
    self.model = LookupCreateModel(model_name, lambda: BranchModel(glb, event_id, report_vars.where_clause))
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 343, in LookupCreateModel
    model = create_fn()
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 3208, in <lambda>
    self.model = LookupCreateModel(model_name, lambda: BranchModel(glb, event_id, report_vars.where_clause))
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 3124, in __init__
    self.fetcher = SQLFetcher(glb, sql, prep, self.AddSample)
  File "tools/perf/scripts/python/exported-sql-viewer.py", line 2658, in __init__
    self.buffer = Array(c_char, self.buffer_size, lock=False)
TypeError: abstract class

This apparently happens because Python can be inconsistent about which
class of the name 'Array' gets imported. Fix by importing explicitly by
name so that only the desired 'Array' gets imported.

Fixes: 8392b74b575c3 ("perf scripts python: exported-sql-viewer.py: Add ability to display all the database tables")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org
---
 tools/perf/scripts/python/exported-sql-viewer.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index b5078d65704e..4a63843f623c 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -125,8 +125,9 @@ if pyside_version_1:
 	from PySide.QtGui import *
 	from PySide.QtSql import *
 
-from decimal import *
-from ctypes import *
+from decimal import Decimal, ROUND_HALF_UP
+from ctypes import CDLL, Structure, create_string_buffer, addressof, sizeof, \
+		   c_void_p, c_bool, c_byte, c_char, c_int, c_uint, c_longlong, c_ulonglong
 from multiprocessing import Process, Array, Value, Event
 
 # xrange is range in Python3
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] perf scripts python: exported-sql-viewer.py: Fix warning display
  2021-05-21  9:20 [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes Adrian Hunter
  2021-05-21  9:20 ` [PATCH 1/3] perf scripts python: exported-sql-viewer.py: Fix copy to clipboard from Top Calls by elapsed Time report Adrian Hunter
  2021-05-21  9:20 ` [PATCH 2/3] perf scripts python: exported-sql-viewer.py: Fix Array TypeError Adrian Hunter
@ 2021-05-21  9:20 ` Adrian Hunter
  2021-05-21 19:31 ` [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes Arnaldo Carvalho de Melo
  3 siblings, 0 replies; 5+ messages in thread
From: Adrian Hunter @ 2021-05-21  9:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa; +Cc: linux-kernel

Deprecation warnings are useful only for the developer, not an end user.
Display warnings only when requested using the python -W option. This
stops the display of warnings like:

 tools/perf/scripts/python/exported-sql-viewer.py:5102: DeprecationWarning:
         an integer is required (got type PySide2.QtCore.Qt.AlignmentFlag).
         Implicit conversion to integers using __int__ is deprecated, and
         may be removed in a future version of Python.
    err = app.exec_()

Since the warning can be fixed only in PySide2, we must wait for it to
be finally fixed there.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org      # v5.3+
---
 tools/perf/scripts/python/exported-sql-viewer.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 4a63843f623c..711d4f9f5645 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -91,6 +91,11 @@
 from __future__ import print_function
 
 import sys
+# Only change warnings if the python -W option was not used
+if not sys.warnoptions:
+	import warnings
+	# PySide2 causes deprecation warnings, ignore them.
+	warnings.filterwarnings("ignore", category=DeprecationWarning)
 import argparse
 import weakref
 import threading
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes
  2021-05-21  9:20 [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes Adrian Hunter
                   ` (2 preceding siblings ...)
  2021-05-21  9:20 ` [PATCH 3/3] perf scripts python: exported-sql-viewer.py: Fix warning display Adrian Hunter
@ 2021-05-21 19:31 ` Arnaldo Carvalho de Melo
  3 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-05-21 19:31 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel

Em Fri, May 21, 2021 at 12:20:50PM +0300, Adrian Hunter escreveu:
> Hi
> 
> Here are 3 minor fixes for stable.
> 

Thanks, applied.

- Arnaldo

 
> Adrian Hunter (3):
>       perf scripts python: exported-sql-viewer.py: Fix copy to clipboard from Top Calls by elapsed Time report
>       perf scripts python: exported-sql-viewer.py: Fix Array TypeError
>       perf scripts python: exported-sql-viewer.py: Fix warning display
> 
>  tools/perf/scripts/python/exported-sql-viewer.py | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> 
> Regards
> Adrian

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-21 19:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21  9:20 [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes Adrian Hunter
2021-05-21  9:20 ` [PATCH 1/3] perf scripts python: exported-sql-viewer.py: Fix copy to clipboard from Top Calls by elapsed Time report Adrian Hunter
2021-05-21  9:20 ` [PATCH 2/3] perf scripts python: exported-sql-viewer.py: Fix Array TypeError Adrian Hunter
2021-05-21  9:20 ` [PATCH 3/3] perf scripts python: exported-sql-viewer.py: Fix warning display Adrian Hunter
2021-05-21 19:31 ` [PATCH 0/3] perf scripts python: exported-sql-viewer.py: Minor fixes Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).