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
Showing the changes to tools/perf/scripts/python/exported-sql-viewer.py (1 of 1 file). Show all
Unified · Split
| @@ -2913,6 +2913,60 @@ class HelpOnlyWindow(QMainWindow): · 2912 unmodified lines | ||
| 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): |
| @@ -3010,6 +3064,7 @@ class MainWindow(QMainWindow): · 91 unmodified lines | ||
| 3010 | 3064 | |
| 3011 | 3065 | help_menu = menu.addMenu("&Help") |
| 3012 | 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 | 3069 | def Try(self, fn): |
| 3015 | 3070 | win = self.mdi_area.activeSubWindow() |
| @@ -3095,6 +3150,10 @@ class MainWindow(QMainWindow): · 79 unmodified lines | ||
| 3095 | 3150 | def Help(self): |
| 3096 | 3151 | HelpWindow(self.glb, self) |
| 3097 | 3152 | |
| 3153 | + def About(self): | |
| 3154 | + dialog = AboutDialog(self.glb, self) | |
| 3155 | + dialog.exec_() | |
| 3156 | + | |
| 3098 | 3157 | # XED Disassembler |
| 3099 | 3158 | |
| 3100 | 3159 | class xed_state_t(Structure): |