diff options
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
| -rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index affed7d149be..6fe553258ce5 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/usr/bin/env python2 | 1 | #!/usr/bin/env python |
| 2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | # exported-sql-viewer.py: view data from sql database | 3 | # exported-sql-viewer.py: view data from sql database |
| 4 | # Copyright (c) 2014-2018, Intel Corporation. | 4 | # Copyright (c) 2014-2018, Intel Corporation. |
| @@ -91,6 +91,7 @@ | |||
| 91 | from __future__ import print_function | 91 | from __future__ import print_function |
| 92 | 92 | ||
| 93 | import sys | 93 | import sys |
| 94 | import argparse | ||
| 94 | import weakref | 95 | import weakref |
| 95 | import threading | 96 | import threading |
| 96 | import string | 97 | import string |
| @@ -104,10 +105,23 @@ except ImportError: | |||
| 104 | glb_nsz = 16 | 105 | glb_nsz = 16 |
| 105 | import re | 106 | import re |
| 106 | import os | 107 | import os |
| 107 | from PySide.QtCore import * | 108 | |
| 108 | from PySide.QtGui import * | ||
| 109 | from PySide.QtSql import * | ||
| 110 | pyside_version_1 = True | 109 | pyside_version_1 = True |
| 110 | if not "--pyside-version-1" in sys.argv: | ||
| 111 | try: | ||
| 112 | from PySide2.QtCore import * | ||
| 113 | from PySide2.QtGui import * | ||
| 114 | from PySide2.QtSql import * | ||
| 115 | from PySide2.QtWidgets import * | ||
| 116 | pyside_version_1 = False | ||
| 117 | except: | ||
| 118 | pass | ||
| 119 | |||
| 120 | if pyside_version_1: | ||
| 121 | from PySide.QtCore import * | ||
| 122 | from PySide.QtGui import * | ||
| 123 | from PySide.QtSql import * | ||
| 124 | |||
| 111 | from decimal import * | 125 | from decimal import * |
| 112 | from ctypes import * | 126 | from ctypes import * |
| 113 | from multiprocessing import Process, Array, Value, Event | 127 | from multiprocessing import Process, Array, Value, Event |
| @@ -2754,7 +2768,7 @@ class WindowMenu(): | |||
| 2754 | action = self.window_menu.addAction(label) | 2768 | action = self.window_menu.addAction(label) |
| 2755 | action.setCheckable(True) | 2769 | action.setCheckable(True) |
| 2756 | action.setChecked(sub_window == self.mdi_area.activeSubWindow()) | 2770 | action.setChecked(sub_window == self.mdi_area.activeSubWindow()) |
| 2757 | action.triggered.connect(lambda x=nr: self.setActiveSubWindow(x)) | 2771 | action.triggered.connect(lambda a=None,x=nr: self.setActiveSubWindow(x)) |
| 2758 | self.window_menu.addAction(action) | 2772 | self.window_menu.addAction(action) |
| 2759 | nr += 1 | 2773 | nr += 1 |
| 2760 | 2774 | ||
| @@ -3114,14 +3128,14 @@ class MainWindow(QMainWindow): | |||
| 3114 | event = event.split(":")[0] | 3128 | event = event.split(":")[0] |
| 3115 | if event == "branches": | 3129 | if event == "branches": |
| 3116 | label = "All branches" if branches_events == 1 else "All branches " + "(id=" + dbid + ")" | 3130 | label = "All branches" if branches_events == 1 else "All branches " + "(id=" + dbid + ")" |
| 3117 | reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewBranchView(x), self)) | 3131 | reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewBranchView(x), self)) |
| 3118 | label = "Selected branches" if branches_events == 1 else "Selected branches " + "(id=" + dbid + ")" | 3132 | label = "Selected branches" if branches_events == 1 else "Selected branches " + "(id=" + dbid + ")" |
| 3119 | reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewSelectedBranchView(x), self)) | 3133 | reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewSelectedBranchView(x), self)) |
| 3120 | 3134 | ||
| 3121 | def TableMenu(self, tables, menu): | 3135 | def TableMenu(self, tables, menu): |
| 3122 | table_menu = menu.addMenu("&Tables") | 3136 | table_menu = menu.addMenu("&Tables") |
| 3123 | for table in tables: | 3137 | for table in tables: |
| 3124 | table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda t=table: self.NewTableView(t), self)) | 3138 | table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda a=None,t=table: self.NewTableView(t), self)) |
| 3125 | 3139 | ||
| 3126 | def NewCallGraph(self): | 3140 | def NewCallGraph(self): |
| 3127 | CallGraphWindow(self.glb, self) | 3141 | CallGraphWindow(self.glb, self) |
| @@ -3361,18 +3375,27 @@ class DBRef(): | |||
| 3361 | # Main | 3375 | # Main |
| 3362 | 3376 | ||
| 3363 | def Main(): | 3377 | def Main(): |
| 3364 | if (len(sys.argv) < 2): | 3378 | usage_str = "exported-sql-viewer.py [--pyside-version-1] <database name>\n" \ |
| 3365 | printerr("Usage is: exported-sql-viewer.py {<database name> | --help-only}"); | 3379 | " or: exported-sql-viewer.py --help-only" |
| 3366 | raise Exception("Too few arguments") | 3380 | ap = argparse.ArgumentParser(usage = usage_str, add_help = False) |
| 3367 | 3381 | ap.add_argument("--pyside-version-1", action='store_true') | |
| 3368 | dbname = sys.argv[1] | 3382 | ap.add_argument("dbname", nargs="?") |
| 3369 | if dbname == "--help-only": | 3383 | ap.add_argument("--help-only", action='store_true') |
| 3384 | args = ap.parse_args() | ||
| 3385 | |||
| 3386 | if args.help_only: | ||
| 3370 | app = QApplication(sys.argv) | 3387 | app = QApplication(sys.argv) |
| 3371 | mainwindow = HelpOnlyWindow() | 3388 | mainwindow = HelpOnlyWindow() |
| 3372 | mainwindow.show() | 3389 | mainwindow.show() |
| 3373 | err = app.exec_() | 3390 | err = app.exec_() |
| 3374 | sys.exit(err) | 3391 | sys.exit(err) |
| 3375 | 3392 | ||
| 3393 | dbname = args.dbname | ||
| 3394 | if dbname is None: | ||
| 3395 | ap.print_usage() | ||
| 3396 | print("Too few arguments") | ||
| 3397 | sys.exit(1) | ||
| 3398 | |||
| 3376 | is_sqlite3 = False | 3399 | is_sqlite3 = False |
| 3377 | try: | 3400 | try: |
| 3378 | f = open(dbname, "rb") | 3401 | f = open(dbname, "rb") |
