Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
b62d18ab 9bc4e4bf

+59
+59
tools/perf/scripts/python/exported-sql-viewer.py
··· 2913 2913 2914 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 2970 # Font resize 2917 2971 2918 2972 def ResizeFont(widget, diff): ··· 3064 3010 3065 3011 help_menu = menu.addMenu("&Help") 3066 3012 help_menu.addAction(CreateAction("&Exported SQL Viewer Help", "Helpful information", self.Help, self, QKeySequence.HelpContents)) 3013 + help_menu.addAction(CreateAction("&About Exported SQL Viewer", "About this application", self.About, self)) 3067 3014 3068 3015 def Try(self, fn): 3069 3016 win = self.mdi_area.activeSubWindow() ··· 3149 3094 3150 3095 def Help(self): 3151 3096 HelpWindow(self.glb, self) 3097 + 3098 + def About(self): 3099 + dialog = AboutDialog(self.glb, self) 3100 + dialog.exec_() 3152 3101 3153 3102 # XED Disassembler 3154 3103