Wed, 29 Aug 2012 17:41:43 +0200
Added a specialized dialog to show the configured routes.
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 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de> |
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 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from PyQt4.QtCore import QProcess, QTimer, pyqtSlot, Qt, QCoreApplication |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | from PyQt4.QtGui import QDialog, QDialogButtonBox, QLineEdit, QTreeWidgetItem |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | from E5Gui import E5MessageBox |
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 .Ui_PyramidRoutesDialog import Ui_PyramidRoutesDialog |
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 | import Preferences |
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 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | class PyramidRoutesDialog(QDialog, Ui_PyramidRoutesDialog): |
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 | 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
|
25 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | 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
|
27 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | Constructor |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | @param project reference to the project object (ProjectPyramid.Project.Project) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | @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
|
32 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | super().__init__(parent) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.setupUi(self) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | 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
|
37 | 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
|
38 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.__project = project |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | self.proc = None |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.buffer = "" |
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.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | QCoreApplication.processEvents() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | def finish(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | Public slot called when the process finished or the user pressed the button. |
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 | if self.proc is not None and \ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | self.proc.state() != QProcess.NotRunning: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | self.proc.terminate() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | 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
|
54 | self.proc.waitForFinished(3000) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | self.inputGroup.setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.inputGroup.hide() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | self.proc = None |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | self.__processBuffer() |
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.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
|
64 | 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
|
65 | self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
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 | 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
|
69 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | 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
|
71 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | @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
|
73 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | 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
|
75 | self.close() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | 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
|
77 | self.finish() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | def __procFinished(self, exitCode, exitStatus): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | 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
|
82 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | @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
|
84 | @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
|
85 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | 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
|
87 | self.finish() |
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 | def __processBuffer(self): |
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 | 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
|
92 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | self.routes.clear() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | if not self.buffer: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | QTreeWidgetItem(self.routes, [self.trUtf8("No routes found.")]) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | self.routes.setHeaderHidden(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | lines = self.buffer.splitlines() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | row = 0 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | headers = [] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | while row < len(lines): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | if lines[row].strip().startswith("---"): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | headerLine = lines[row - 1] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | headers = headerLine.split() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | break |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | if headers: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | self.routes.setHeaderLabels(headers) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | self.routes.setHeaderHidden(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | splitCount = len(headers) - 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | while row < len(lines): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | line = lines[row].strip() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | parts = line.split(None, splitCount) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | QTreeWidgetItem(self.routes, parts) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | 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
|
119 | self.routes.resizeColumnToContents(column) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | def start(self, projectPath): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | 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
|
124 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | @param command command to start (string) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | @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
|
127 | @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
|
128 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | QTreeWidgetItem(self.routes, [self.trUtf8("Getting routes...")]) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | self.routes.setHeaderHidden(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | self.errorGroup.hide() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | self.normal = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | self.intercept = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | self.buttonBox.button(QDialogButtonBox.Cancel).setFocus(Qt.OtherFocusReason) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | self.proc = QProcess() |
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.proc.finished.connect(self.__procFinished) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | 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
|
145 | 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
|
146 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | cmd = self.__project.getPyramidCommand("proutes") |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | args = [] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | args.append("development.ini") |
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 | if projectPath: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | self.proc.setWorkingDirectory(projectPath) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | self.proc.start(cmd, args) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | procStarted = self.proc.waitForStarted() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | if not procStarted: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | self.buttonBox.setFocus() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | self.inputGroup.setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | E5MessageBox.critical(self, |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | self.trUtf8('Process Generation Error'), |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | self.trUtf8( |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | '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
|
162 | '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
|
163 | ).format(cmd)) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | self.inputGroup.setEnabled(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | self.inputGroup.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | return procStarted |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | def __readStdout(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | 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
|
172 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | 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
|
174 | delayed processing. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | 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
|
177 | out = str(self.proc.readAllStandardOutput(), |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | Preferences.getSystem("IOEncoding"), |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | 'replace') |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | self.buffer += out |
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 | def __readStderr(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | 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
|
185 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | 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
|
187 | error pane. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | 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
|
190 | err = str(self.proc.readAllStandardError(), |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | Preferences.getSystem("IOEncoding"), |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | 'replace') |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | self.errorGroup.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | self.errors.insertPlainText(err) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | self.errors.ensureCursorVisible() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | QCoreApplication.processEvents() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | 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
|
200 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | 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
|
202 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | @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
|
204 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | if isOn: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | self.input.setEchoMode(QLineEdit.Password) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | self.input.setEchoMode(QLineEdit.Normal) |
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 | @pyqtSlot() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | def on_sendButton_clicked(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | 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
|
214 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | input = self.input.text() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | input += os.linesep |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | if self.passwordCheckBox.isChecked(): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | self.errors.insertPlainText(os.linesep) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | self.errors.ensureCursorVisible() |
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 | self.proc.write(input) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | self.passwordCheckBox.setChecked(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | self.input.clear() |
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 | def on_input_returnPressed(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | 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
|
230 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | self.intercept = True |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | self.on_sendButton_clicked() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | def keyPressEvent(self, evt): |
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 | 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
|
237 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | @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
|
239 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | if self.intercept: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | self.intercept = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | evt.accept() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | return |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | super().keyPressEvent(evt) |