25 """ |
25 """ |
26 def __init__(self, project, parent=None): |
26 def __init__(self, project, parent=None): |
27 """ |
27 """ |
28 Constructor |
28 Constructor |
29 |
29 |
30 @param project reference to the project object (ProjectPyramid.Project.Project) |
30 @param project reference to the project object |
|
31 (ProjectPyramid.Project.Project) |
31 @param parent reference to the parent widget (QWidget) |
32 @param parent reference to the parent widget (QWidget) |
32 """ |
33 """ |
33 super().__init__(parent) |
34 super().__init__(parent) |
34 self.setupUi(self) |
35 self.setupUi(self) |
35 |
36 |
43 self.show() |
44 self.show() |
44 QCoreApplication.processEvents() |
45 QCoreApplication.processEvents() |
45 |
46 |
46 def finish(self): |
47 def finish(self): |
47 """ |
48 """ |
48 Public slot called when the process finished or the user pressed the button. |
49 Public slot called when the process finished or the user pressed the |
|
50 button. |
49 """ |
51 """ |
50 if self.proc is not None and \ |
52 if self.proc is not None and \ |
51 self.proc.state() != QProcess.NotRunning: |
53 self.proc.state() != QProcess.NotRunning: |
52 self.proc.terminate() |
54 self.proc.terminate() |
53 QTimer.singleShot(2000, self.proc.kill) |
55 QTimer.singleShot(2000, self.proc.kill) |
61 self.__processBuffer() |
63 self.__processBuffer() |
62 |
64 |
63 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
65 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
64 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
66 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
65 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
67 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
66 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
68 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
69 Qt.OtherFocusReason) |
67 |
70 |
68 def on_buttonBox_clicked(self, button): |
71 def on_buttonBox_clicked(self, button): |
69 """ |
72 """ |
70 Private slot called by a button of the button box clicked. |
73 Private slot called by a button of the button box clicked. |
71 |
74 |
120 |
123 |
121 def start(self, projectPath): |
124 def start(self, projectPath): |
122 """ |
125 """ |
123 Public slot used to start the process. |
126 Public slot used to start the process. |
124 |
127 |
125 @param command command to start (string) |
|
126 @param projectPath path to the Pyramid project (string) |
128 @param projectPath path to the Pyramid project (string) |
127 @return flag indicating a successful start of the process |
129 @return flag indicating a successful start of the process |
128 """ |
130 """ |
129 QTreeWidgetItem(self.routes, [self.trUtf8("Getting routes...")]) |
131 QTreeWidgetItem(self.routes, [self.trUtf8("Getting routes...")]) |
130 self.routes.setHeaderHidden(True) |
132 self.routes.setHeaderHidden(True) |
134 self.intercept = False |
136 self.intercept = False |
135 |
137 |
136 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
138 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
137 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
139 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
138 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
140 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
139 self.buttonBox.button(QDialogButtonBox.Cancel).setFocus(Qt.OtherFocusReason) |
141 self.buttonBox.button(QDialogButtonBox.Cancel).setFocus( |
|
142 Qt.OtherFocusReason) |
140 |
143 |
141 self.proc = QProcess() |
144 self.proc = QProcess() |
142 |
145 |
143 self.proc.finished.connect(self.__procFinished) |
146 self.proc.finished.connect(self.__procFinished) |
144 self.proc.readyReadStandardOutput.connect(self.__readStdout) |
147 self.proc.readyReadStandardOutput.connect(self.__readStdout) |
153 self.proc.start(cmd, args) |
156 self.proc.start(cmd, args) |
154 procStarted = self.proc.waitForStarted() |
157 procStarted = self.proc.waitForStarted() |
155 if not procStarted: |
158 if not procStarted: |
156 self.buttonBox.setFocus() |
159 self.buttonBox.setFocus() |
157 self.inputGroup.setEnabled(False) |
160 self.inputGroup.setEnabled(False) |
158 E5MessageBox.critical(self, |
161 E5MessageBox.critical( |
|
162 self, |
159 self.trUtf8('Process Generation Error'), |
163 self.trUtf8('Process Generation Error'), |
160 self.trUtf8( |
164 self.trUtf8( |
161 'The process {0} could not be started. ' |
165 'The process {0} could not be started. ' |
162 'Ensure, that it is in the search path.' |
166 'Ensure, that it is in the search path.' |
163 ).format(cmd)) |
167 ).format(cmd)) |
173 It reads the output of the process and appends it to a buffer for |
177 It reads the output of the process and appends it to a buffer for |
174 delayed processing. |
178 delayed processing. |
175 """ |
179 """ |
176 if self.proc is not None: |
180 if self.proc is not None: |
177 out = str(self.proc.readAllStandardOutput(), |
181 out = str(self.proc.readAllStandardOutput(), |
178 Preferences.getSystem("IOEncoding"), |
182 Preferences.getSystem("IOEncoding"), |
179 'replace') |
183 'replace') |
180 self.buffer += out |
184 self.buffer += out |
181 |
185 |
182 def __readStderr(self): |
186 def __readStderr(self): |
183 """ |
187 """ |
184 Private slot to handle the readyReadStandardError signal. |
188 Private slot to handle the readyReadStandardError signal. |
186 It reads the error output of the process and inserts it into the |
190 It reads the error output of the process and inserts it into the |
187 error pane. |
191 error pane. |
188 """ |
192 """ |
189 if self.proc is not None: |
193 if self.proc is not None: |
190 err = str(self.proc.readAllStandardError(), |
194 err = str(self.proc.readAllStandardError(), |
191 Preferences.getSystem("IOEncoding"), |
195 Preferences.getSystem("IOEncoding"), |
192 'replace') |
196 'replace') |
193 self.errorGroup.show() |
197 self.errorGroup.show() |
194 self.errors.insertPlainText(err) |
198 self.errors.insertPlainText(err) |
195 self.errors.ensureCursorVisible() |
199 self.errors.ensureCursorVisible() |
196 |
200 |
197 QCoreApplication.processEvents() |
201 QCoreApplication.processEvents() |