Wed, 30 Dec 2020 11:02:09 +0100
Updated copyright for 2021.
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
143
4ef44e854b39
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
138
diff
changeset
|
3 | # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog showing the available routes. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import os |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
74
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
12 | from PyQt5.QtCore import QProcess, QTimer, pyqtSlot, Qt, QCoreApplication |
138
72ebb74aa42d
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
132
diff
changeset
|
13 | from PyQt5.QtWidgets import ( |
72ebb74aa42d
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
132
diff
changeset
|
14 | QDialog, QDialogButtonBox, QLineEdit, QTreeWidgetItem |
72ebb74aa42d
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
132
diff
changeset
|
15 | ) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | from E5Gui import E5MessageBox |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | from .Ui_PyramidRoutesDialog import Ui_PyramidRoutesDialog |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | import Preferences |
123
97e5d21bd503
PyramidDialog, PyramidRoutesDialog: fixed a bug causing sending some input to the Pyramid process to fail.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
112
diff
changeset
|
22 | from Globals import strToQByteArray |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | class PyramidRoutesDialog(QDialog, Ui_PyramidRoutesDialog): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Class implementing a dialog showing the available routes. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | def __init__(self, project, parent=None): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | Constructor |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
33 | @param project reference to the project object |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
34 | (ProjectPyramid.Project.Project) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | @param parent reference to the parent widget (QWidget) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | """ |
56
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
37 | super(PyramidRoutesDialog, self).__init__(parent) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.setupUi(self) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.__project = project |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.proc = None |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.buffer = "" |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | self.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | QCoreApplication.processEvents() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | def finish(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | """ |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
52 | Public slot called when the process finished or the user pressed the |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
53 | button. |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | """ |
138
72ebb74aa42d
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
132
diff
changeset
|
55 | if ( |
72ebb74aa42d
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
132
diff
changeset
|
56 | self.proc is not None and |
72ebb74aa42d
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
132
diff
changeset
|
57 | self.proc.state() != QProcess.NotRunning |
72ebb74aa42d
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
132
diff
changeset
|
58 | ): |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | self.proc.terminate() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | QTimer.singleShot(2000, self.proc.kill) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | self.proc.waitForFinished(3000) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | self.inputGroup.setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | self.inputGroup.hide() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | self.proc = None |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | self.__processBuffer() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
73 | self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
74 | Qt.OtherFocusReason) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | def on_buttonBox_clicked(self, button): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | Private slot called by a button of the button box clicked. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | @param button button that was clicked (QAbstractButton) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | if button == self.buttonBox.button(QDialogButtonBox.Close): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | self.close() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | self.finish() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | def __procFinished(self, exitCode, exitStatus): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | Private slot connected to the finished signal. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | @param exitCode exit code of the process (integer) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | @param exitStatus exit status of the process (QProcess.ExitStatus) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | self.normal = (exitStatus == QProcess.NormalExit) and (exitCode == 0) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | self.finish() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | def __processBuffer(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | Private slot to process the output buffer of the proutes command. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | self.routes.clear() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | if not self.buffer: |
74
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
104 | QTreeWidgetItem(self.routes, [self.tr("No routes found.")]) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | self.routes.setHeaderHidden(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | lines = self.buffer.splitlines() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | row = 0 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | headers = [] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | while row < len(lines): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | if lines[row].strip().startswith("---"): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | headerLine = lines[row - 1] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | headers = headerLine.split() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | break |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | if headers: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | self.routes.setHeaderLabels(headers) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | self.routes.setHeaderHidden(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | splitCount = len(headers) - 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | while row < len(lines): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | line = lines[row].strip() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | parts = line.split(None, splitCount) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | QTreeWidgetItem(self.routes, parts) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | for column in range(len(headers)): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | self.routes.resizeColumnToContents(column) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | def start(self, projectPath): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | Public slot used to start the process. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | @param projectPath path to the Pyramid project (string) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | @return flag indicating a successful start of the process |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | """ |
74
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
136 | QTreeWidgetItem(self.routes, [self.tr("Getting routes...")]) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | self.routes.setHeaderHidden(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | self.errorGroup.hide() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | self.normal = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | self.intercept = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
146 | self.buttonBox.button(QDialogButtonBox.Cancel).setFocus( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
147 | Qt.OtherFocusReason) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | self.proc = QProcess() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | self.proc.finished.connect(self.__procFinished) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | self.proc.readyReadStandardOutput.connect(self.__readStdout) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | self.proc.readyReadStandardError.connect(self.__readStderr) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | cmd = self.__project.getPyramidCommand("proutes") |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | args = [] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | args.append("development.ini") |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | if projectPath: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | self.proc.setWorkingDirectory(projectPath) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | self.proc.start(cmd, args) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | procStarted = self.proc.waitForStarted() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | if not procStarted: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | self.buttonBox.setFocus() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | self.inputGroup.setEnabled(False) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
166 | E5MessageBox.critical( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
167 | self, |
74
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
168 | self.tr('Process Generation Error'), |
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
169 | self.tr( |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | 'The process {0} could not be started. ' |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | 'Ensure, that it is in the search path.' |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | ).format(cmd)) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | self.inputGroup.setEnabled(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | self.inputGroup.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | return procStarted |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | def __readStdout(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | Private slot to handle the readyReadStandardOutput signal. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | It reads the output of the process and appends it to a buffer for |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | delayed processing. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | if self.proc is not None: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | out = str(self.proc.readAllStandardOutput(), |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
187 | Preferences.getSystem("IOEncoding"), |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
188 | 'replace') |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | self.buffer += out |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | def __readStderr(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | Private slot to handle the readyReadStandardError signal. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | It reads the error output of the process and inserts it into the |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | error pane. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | if self.proc is not None: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | err = str(self.proc.readAllStandardError(), |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
200 | Preferences.getSystem("IOEncoding"), |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
201 | 'replace') |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | self.errorGroup.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | self.errors.insertPlainText(err) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | self.errors.ensureCursorVisible() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | QCoreApplication.processEvents() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | def on_passwordCheckBox_toggled(self, isOn): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | Private slot to handle the password checkbox toggled. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | @param isOn flag indicating the status of the check box (boolean) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | if isOn: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | self.input.setEchoMode(QLineEdit.Password) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | self.input.setEchoMode(QLineEdit.Normal) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | @pyqtSlot() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | def on_sendButton_clicked(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | Private slot to send the input to the subversion process. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | """ |
106
2086bda4a893
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
99
diff
changeset
|
224 | inputTxt = self.input.text() |
2086bda4a893
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
99
diff
changeset
|
225 | inputTxt += os.linesep |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | if self.passwordCheckBox.isChecked(): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | self.errors.insertPlainText(os.linesep) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | self.errors.ensureCursorVisible() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | |
123
97e5d21bd503
PyramidDialog, PyramidRoutesDialog: fixed a bug causing sending some input to the Pyramid process to fail.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
112
diff
changeset
|
231 | self.proc.write(strToQByteArray(inputTxt)) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | self.passwordCheckBox.setChecked(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | self.input.clear() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | def on_input_returnPressed(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | Private slot to handle the press of the return key in the input field. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | self.intercept = True |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | self.on_sendButton_clicked() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | def keyPressEvent(self, evt): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | Protected slot to handle a key press event. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | @param evt the key press event (QKeyEvent) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | if self.intercept: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | self.intercept = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | evt.accept() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | return |
56
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
253 | super(PyramidRoutesDialog, self).keyPressEvent(evt) |