Sun, 29 Nov 2020 16:04:25 +0100
Fixed some code style issues.
35
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de> |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog showing a summary of all created.migrations. |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QEventLoop, QTimer |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from PyQt5.QtGui import QGuiApplication |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from PyQt5.QtWidgets import ( |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | QDialog, QDialogButtonBox, QAbstractButton, QTreeWidgetItem |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | ) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | from E5Gui import E5MessageBox |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | from .Ui_MigrateSummaryDialog import Ui_MigrateSummaryDialog |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | class MigrateSummaryDialog(QDialog, Ui_MigrateSummaryDialog): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | Class implementing a dialog showing a summary of all created.migrations. |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | def __init__(self, project, migrateProject, migrations="", parent=None): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Constructor |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | |
36
548dea93941c
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
29 | @param project reference to the project object |
548dea93941c
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
30 | @type Project |
35
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | @param migrateProject reference to the migrate project extension |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | @type MigrateProject |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | @param migrations directory path containing the migrations |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | @type str |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | @param parent reference to the parent widget |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | @type QWidget |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | super(MigrateSummaryDialog, self).__init__(parent) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.setupUi(self) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.__refreshButton = self.buttonBox.addButton( |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | self.tr("Refresh"), QDialogButtonBox.ActionRole) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.__refreshButton.clicked.connect(self.showSummary) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.__project = project |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | self.__migrateProject = migrateProject |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | self.__migrations = migrations |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.__process = None |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | def showSummary(self): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | Public method to show the migrations summary. |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | workdir, env = self.__project.prepareRuntimeEnvironment() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | if env is not None: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | self.show() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.raise_() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | self.buttonBox.button(QDialogButtonBox.Cancel).setFocus( |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | Qt.OtherFocusReason) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | QGuiApplication.processEvents(QEventLoop.ExcludeUserInputEvents) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | command = self.__project.getFlaskCommand() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | self.__process = QProcess() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | self.__process.setProcessEnvironment(env) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | self.__process.setWorkingDirectory(workdir) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | args = ["db", "history", "--indicate-current"] |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | if self.__migrations: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | args += ["--directory", self.__migrations] |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | QGuiApplication.setOverrideCursor(Qt.WaitCursor) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | self.__process.start(command, args) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | ok = self.__process.waitForStarted(10000) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | if ok: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | ok = self.__process.waitForFinished(10000) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | if ok: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | out = str(self.__process.readAllStandardOutput(), "utf-8") |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | self.__processOutput(out) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | else: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | E5MessageBox.critical( |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | None, |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | self.tr("Migrations Summary"), |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | self.tr("""The Flask process did not finish within""" |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | """ 10 seconds.""")) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | else: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | E5MessageBox.critical( |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | None, |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | self.tr("Migrations Summary"), |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | self.tr("""The Flask process could not be started.""")) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | for column in range(self.summaryWidget.columnCount()): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | self.summaryWidget.resizeColumnToContents(column) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | QGuiApplication.restoreOverrideCursor() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | Qt.OtherFocusReason) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | def __processOutput(self, output): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | Private method to process the flask output and populate the summary |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | list. |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | @param output output of the flask process |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | @type str |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | self.summaryWidget.clear() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | self.upgradeButton.setEnabled(False) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | self.downgradeButton.setEnabled(False) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | lines = output.splitlines() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | for line in lines: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | isCurrent = False |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | oldRev, rest = line.split("->") |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | rest, message = rest.split(",", 1) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | newRev, *labels = rest.split() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | if labels: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | labelList = [ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | label.replace("(", "").replace(")", "") |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | for label in labels |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | ] |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | labelsStr = ", ".join(labelList) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | if "current" in labelList: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | isCurrent = True |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | else: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | labelsStr = "" |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | itm = QTreeWidgetItem(self.summaryWidget, [ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | oldRev.strip(), |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | newRev.strip(), |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | message.strip(), |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | labelsStr, |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | ]) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | if isCurrent: |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | font = itm.font(0) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | font.setBold(True) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | for column in range(self.summaryWidget.columnCount()): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | itm.setFont(column, font) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | @pyqtSlot() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | def on_summaryWidget_itemSelectionChanged(self): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | Private slot to handle the selection of an entry. |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | enable = bool(self.summaryWidget.selectedItems()) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | self.upgradeButton.setEnabled(enable) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | self.downgradeButton.setEnabled(enable) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | @pyqtSlot() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | def on_upgradeButton_clicked(self): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | """ |
36
548dea93941c
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
158 | Private slot to upgrade to the selected revision. |
35
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | itm = self.summaryWidget.selectedItems()[0] |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | rev = itm.text(1) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | self.__migrateProject.upgradeDatabase(revision=rev) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | self.showSummary() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | @pyqtSlot() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | def on_downgradeButton_clicked(self): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | """ |
36
548dea93941c
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
168 | Private slot to downgrade to the selected revision. |
35
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | itm = self.summaryWidget.selectedItems()[0] |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | rev = itm.text(1) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | self.__migrateProject.downgradeDatabase(revision=rev) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | self.showSummary() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | @pyqtSlot(QAbstractButton) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | def on_buttonBox_clicked(self, button): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | """ |
36
548dea93941c
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
178 | Private slot handling a button press of the button box. |
35
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | @param button reference to the pressed button |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | @type QAbstractButton |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | if button is self.buttonBox.button(QDialogButtonBox.Cancel): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | self.__cancelProcess() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | @pyqtSlot() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | def __cancelProcess(self): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | Private slot to terminate the current process. |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | """ |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | if ( |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | self.__process is not None and |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | self.__process.state() != QProcess.NotRunning |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | ): |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | self.__process.terminate() |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | QTimer.singleShot(2000, self.__process.kill) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | self.__process.waitForFinished(3000) |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | |
65a377b7a52c
Added actions to show a migrations summary and migrations history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | self.__process = None |