diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2019-02-22 02:27:22 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-22 14:52:07 -0500 |
commit | 0924cd687fe7bd4fdf81721c2420b65234b16357 (patch) | |
tree | 7e366d75bee589b48a819aca9d8276c4dd71d25d /tools/perf/scripts/python/exported-sql-viewer.py | |
parent | 8c90fef9a84d5309c12a8c24146494bcf2dd25c4 (diff) |
perf scripts python: exported-sql-viewer.py: Factor out ReportDialogBase
Factor out ReportDialogBase so it can be re-used.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
-rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index 7bd5263d3f39..d3ffb3e9d1fc 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
@@ -1693,34 +1693,25 @@ class SQLTableDialogDataItem(): | |||
1693 | return False | 1693 | return False |
1694 | return True | 1694 | return True |
1695 | 1695 | ||
1696 | # Selected branch report creation dialog | 1696 | # Report Dialog Base |
1697 | 1697 | ||
1698 | class SelectedBranchDialog(QDialog): | 1698 | class ReportDialogBase(QDialog): |
1699 | 1699 | ||
1700 | def __init__(self, glb, parent=None): | 1700 | def __init__(self, glb, title, items, partial, parent=None): |
1701 | super(SelectedBranchDialog, self).__init__(parent) | 1701 | super(ReportDialogBase, self).__init__(parent) |
1702 | 1702 | ||
1703 | self.glb = glb | 1703 | self.glb = glb |
1704 | 1704 | ||
1705 | self.name = "" | 1705 | self.name = "" |
1706 | self.where_clause = "" | 1706 | self.where_clause = "" |
1707 | 1707 | ||
1708 | self.setWindowTitle("Selected Branches") | 1708 | self.setWindowTitle(title) |
1709 | self.setMinimumWidth(600) | 1709 | self.setMinimumWidth(600) |
1710 | 1710 | ||
1711 | items = ( | ||
1712 | ("Report name:", "Enter a name to appear in the window title bar", "", "", "", ""), | ||
1713 | ("Time ranges:", "Enter time ranges", "<timeranges>", "", "samples.id", ""), | ||
1714 | ("CPUs:", "Enter CPUs or ranges e.g. 0,5-6", "<ranges>", "", "cpu", ""), | ||
1715 | ("Commands:", "Only branches with these commands will be included", "comms", "comm", "comm_id", ""), | ||
1716 | ("PIDs:", "Only branches with these process IDs will be included", "threads", "pid", "thread_id", ""), | ||
1717 | ("TIDs:", "Only branches with these thread IDs will be included", "threads", "tid", "thread_id", ""), | ||
1718 | ("DSOs:", "Only branches with these DSOs will be included", "dsos", "short_name", "samples.dso_id", "to_dso_id"), | ||
1719 | ("Symbols:", "Only branches with these symbols will be included", "symbols", "name", "symbol_id", "to_symbol_id"), | ||
1720 | ("Raw SQL clause: ", "Enter a raw SQL WHERE clause", "", "", "", ""), | ||
1721 | ) | ||
1722 | self.data_items = [SQLTableDialogDataItem(glb, *x, parent=self) for x in items] | 1711 | self.data_items = [SQLTableDialogDataItem(glb, *x, parent=self) for x in items] |
1723 | 1712 | ||
1713 | self.partial = partial | ||
1714 | |||
1724 | self.grid = QGridLayout() | 1715 | self.grid = QGridLayout() |
1725 | 1716 | ||
1726 | for row in xrange(len(self.data_items)): | 1717 | for row in xrange(len(self.data_items)): |
@@ -1764,7 +1755,10 @@ class SelectedBranchDialog(QDialog): | |||
1764 | self.where_clause += " AND " | 1755 | self.where_clause += " AND " |
1765 | self.where_clause += d.value | 1756 | self.where_clause += d.value |
1766 | if len(self.where_clause): | 1757 | if len(self.where_clause): |
1767 | self.where_clause = " AND ( " + self.where_clause + " ) " | 1758 | if self.partial: |
1759 | self.where_clause = " AND ( " + self.where_clause + " ) " | ||
1760 | else: | ||
1761 | self.where_clause = " WHERE " + self.where_clause + " " | ||
1768 | else: | 1762 | else: |
1769 | self.ShowMessage("No selection") | 1763 | self.ShowMessage("No selection") |
1770 | return | 1764 | return |
@@ -1776,6 +1770,25 @@ class SelectedBranchDialog(QDialog): | |||
1776 | def ClearMessage(self): | 1770 | def ClearMessage(self): |
1777 | self.status.setText("") | 1771 | self.status.setText("") |
1778 | 1772 | ||
1773 | # Selected branch report creation dialog | ||
1774 | |||
1775 | class SelectedBranchDialog(ReportDialogBase): | ||
1776 | |||
1777 | def __init__(self, glb, parent=None): | ||
1778 | title = "Selected Branches" | ||
1779 | items = ( | ||
1780 | ("Report name:", "Enter a name to appear in the window title bar", "", "", "", ""), | ||
1781 | ("Time ranges:", "Enter time ranges", "<timeranges>", "", "samples.id", ""), | ||
1782 | ("CPUs:", "Enter CPUs or ranges e.g. 0,5-6", "<ranges>", "", "cpu", ""), | ||
1783 | ("Commands:", "Only branches with these commands will be included", "comms", "comm", "comm_id", ""), | ||
1784 | ("PIDs:", "Only branches with these process IDs will be included", "threads", "pid", "thread_id", ""), | ||
1785 | ("TIDs:", "Only branches with these thread IDs will be included", "threads", "tid", "thread_id", ""), | ||
1786 | ("DSOs:", "Only branches with these DSOs will be included", "dsos", "short_name", "samples.dso_id", "to_dso_id"), | ||
1787 | ("Symbols:", "Only branches with these symbols will be included", "symbols", "name", "symbol_id", "to_symbol_id"), | ||
1788 | ("Raw SQL clause: ", "Enter a raw SQL WHERE clause", "", "", "", ""), | ||
1789 | ) | ||
1790 | super(SelectedBranchDialog, self).__init__(glb, title, items, True, parent) | ||
1791 | |||
1779 | # Event list | 1792 | # Event list |
1780 | 1793 | ||
1781 | def GetEventList(db): | 1794 | def GetEventList(db): |