diff options
| author | Adrian Hunter <adrian.hunter@intel.com> | 2019-05-03 08:08:28 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-05-15 15:36:47 -0400 |
| commit | b62d18aba1109506c1926ab7b564c4ac3bd48786 (patch) | |
| tree | c796b72b889b9ff94fc39e92e8c36677d57b2d2c /tools/perf/scripts/python | |
| parent | 9bc4e4bfe6169343a8f019cd5d7843a558b78363 (diff) | |
perf scripts python: exported-sql-viewer.py: Add 'About' dialog box
With support for Python 2 or 3 and PySide 1 or 2 (Qt 4 or 5), it is
useful to see what versions are in use. Add an 'About' dialog box that
displays Python, PySide, Qt and database server (SQLite or PostgreSQL)
version numbers.
Committer testing:
$ python ~acme/libexec/perf-core/scripts/python/exported-sql-viewer.py ~/c/adrian.hunter/simple-retpoline.db
Then go to 'Help', then 'About', select all the lines with the mouse
press 'Control+C', then, on the same terminal press control+shift+V
which shows my current environment:
Python version: 2.7.16
PySide version: 1
Qt version: 4.8.7
SQLite version: 3.26.0
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190503120828.25326-7-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python')
| -rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index affd80ebcae0..affed7d149be 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
| @@ -2913,6 +2913,60 @@ class HelpOnlyWindow(QMainWindow): | |||
| 2913 | 2913 | ||
| 2914 | self.setCentralWidget(self.text) | 2914 | self.setCentralWidget(self.text) |
| 2915 | 2915 | ||
| 2916 | # PostqreSQL server version | ||
| 2917 | |||
| 2918 | def PostqreSQLServerVersion(db): | ||
| 2919 | query = QSqlQuery(db) | ||
| 2920 | QueryExec(query, "SELECT VERSION()") | ||
| 2921 | if query.next(): | ||
| 2922 | v_str = query.value(0) | ||
| 2923 | v_list = v_str.strip().split(" ") | ||
| 2924 | if v_list[0] == "PostgreSQL" and v_list[2] == "on": | ||
| 2925 | return v_list[1] | ||
| 2926 | return v_str | ||
| 2927 | return "Unknown" | ||
| 2928 | |||
| 2929 | # SQLite version | ||
| 2930 | |||
| 2931 | def SQLiteVersion(db): | ||
| 2932 | query = QSqlQuery(db) | ||
| 2933 | QueryExec(query, "SELECT sqlite_version()") | ||
| 2934 | if query.next(): | ||
| 2935 | return query.value(0) | ||
| 2936 | return "Unknown" | ||
| 2937 | |||
| 2938 | # About dialog | ||
| 2939 | |||
| 2940 | class AboutDialog(QDialog): | ||
| 2941 | |||
| 2942 | def __init__(self, glb, parent=None): | ||
| 2943 | super(AboutDialog, self).__init__(parent) | ||
| 2944 | |||
| 2945 | self.setWindowTitle("About Exported SQL Viewer") | ||
| 2946 | self.setMinimumWidth(300) | ||
| 2947 | |||
| 2948 | pyside_version = "1" if pyside_version_1 else "2" | ||
| 2949 | |||
| 2950 | text = "<pre>" | ||
| 2951 | text += "Python version: " + sys.version.split(" ")[0] + "\n" | ||
| 2952 | text += "PySide version: " + pyside_version + "\n" | ||
| 2953 | text += "Qt version: " + qVersion() + "\n" | ||
| 2954 | if glb.dbref.is_sqlite3: | ||
| 2955 | text += "SQLite version: " + SQLiteVersion(glb.db) + "\n" | ||
| 2956 | else: | ||
| 2957 | text += "PostqreSQL version: " + PostqreSQLServerVersion(glb.db) + "\n" | ||
| 2958 | text += "</pre>" | ||
| 2959 | |||
| 2960 | self.text = QTextBrowser() | ||
| 2961 | self.text.setHtml(text) | ||
| 2962 | self.text.setReadOnly(True) | ||
| 2963 | self.text.setOpenExternalLinks(True) | ||
| 2964 | |||
| 2965 | self.vbox = QVBoxLayout() | ||
| 2966 | self.vbox.addWidget(self.text) | ||
| 2967 | |||
| 2968 | self.setLayout(self.vbox); | ||
| 2969 | |||
| 2916 | # Font resize | 2970 | # Font resize |
| 2917 | 2971 | ||
| 2918 | def ResizeFont(widget, diff): | 2972 | def ResizeFont(widget, diff): |
| @@ -3010,6 +3064,7 @@ class MainWindow(QMainWindow): | |||
| 3010 | 3064 | ||
| 3011 | help_menu = menu.addMenu("&Help") | 3065 | help_menu = menu.addMenu("&Help") |
| 3012 | help_menu.addAction(CreateAction("&Exported SQL Viewer Help", "Helpful information", self.Help, self, QKeySequence.HelpContents)) | 3066 | help_menu.addAction(CreateAction("&Exported SQL Viewer Help", "Helpful information", self.Help, self, QKeySequence.HelpContents)) |
| 3067 | help_menu.addAction(CreateAction("&About Exported SQL Viewer", "About this application", self.About, self)) | ||
| 3013 | 3068 | ||
| 3014 | def Try(self, fn): | 3069 | def Try(self, fn): |
| 3015 | win = self.mdi_area.activeSubWindow() | 3070 | win = self.mdi_area.activeSubWindow() |
| @@ -3095,6 +3150,10 @@ class MainWindow(QMainWindow): | |||
| 3095 | def Help(self): | 3150 | def Help(self): |
| 3096 | HelpWindow(self.glb, self) | 3151 | HelpWindow(self.glb, self) |
| 3097 | 3152 | ||
| 3153 | def About(self): | ||
| 3154 | dialog = AboutDialog(self.glb, self) | ||
| 3155 | dialog.exec_() | ||
| 3156 | |||
| 3098 | # XED Disassembler | 3157 | # XED Disassembler |
| 3099 | 3158 | ||
| 3100 | class xed_state_t(Structure): | 3159 | class xed_state_t(Structure): |
