31 """ |
31 """ |
32 def __init__(self, project, parent=None): |
32 def __init__(self, project, parent=None): |
33 """ |
33 """ |
34 Constructor |
34 Constructor |
35 |
35 |
36 @param project reference to the project object (ProjectPyramid.Project.Project) |
36 @param project reference to the project object |
|
37 (ProjectPyramid.Project.Project) |
37 @param parent reference to the parent widget (QWidget) |
38 @param parent reference to the parent widget (QWidget) |
38 """ |
39 """ |
39 super(PyramidRoutesDialog, self).__init__(parent) |
40 super(PyramidRoutesDialog, self).__init__(parent) |
40 self.setupUi(self) |
41 self.setupUi(self) |
41 |
42 |
49 self.show() |
50 self.show() |
50 QCoreApplication.processEvents() |
51 QCoreApplication.processEvents() |
51 |
52 |
52 def finish(self): |
53 def finish(self): |
53 """ |
54 """ |
54 Public slot called when the process finished or the user pressed the button. |
55 Public slot called when the process finished or the user pressed the |
|
56 button. |
55 """ |
57 """ |
56 if self.proc is not None and \ |
58 if self.proc is not None and \ |
57 self.proc.state() != QProcess.NotRunning: |
59 self.proc.state() != QProcess.NotRunning: |
58 self.proc.terminate() |
60 self.proc.terminate() |
59 QTimer.singleShot(2000, self.proc.kill) |
61 QTimer.singleShot(2000, self.proc.kill) |
67 self.__processBuffer() |
69 self.__processBuffer() |
68 |
70 |
69 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
71 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
70 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
72 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
71 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
73 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
72 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
74 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
75 Qt.OtherFocusReason) |
73 |
76 |
74 def on_buttonBox_clicked(self, button): |
77 def on_buttonBox_clicked(self, button): |
75 """ |
78 """ |
76 Private slot called by a button of the button box clicked. |
79 Private slot called by a button of the button box clicked. |
77 |
80 |
126 |
129 |
127 def start(self, projectPath): |
130 def start(self, projectPath): |
128 """ |
131 """ |
129 Public slot used to start the process. |
132 Public slot used to start the process. |
130 |
133 |
131 @param command command to start (string) |
|
132 @param projectPath path to the Pyramid project (string) |
134 @param projectPath path to the Pyramid project (string) |
133 @return flag indicating a successful start of the process |
135 @return flag indicating a successful start of the process |
134 """ |
136 """ |
135 QTreeWidgetItem(self.routes, [self.trUtf8("Getting routes...")]) |
137 QTreeWidgetItem(self.routes, [self.trUtf8("Getting routes...")]) |
136 self.routes.setHeaderHidden(True) |
138 self.routes.setHeaderHidden(True) |
140 self.intercept = False |
142 self.intercept = False |
141 |
143 |
142 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
144 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
143 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
145 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
144 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
146 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
145 self.buttonBox.button(QDialogButtonBox.Cancel).setFocus(Qt.OtherFocusReason) |
147 self.buttonBox.button(QDialogButtonBox.Cancel).setFocus( |
|
148 Qt.OtherFocusReason) |
146 |
149 |
147 self.proc = QProcess() |
150 self.proc = QProcess() |
148 |
151 |
149 self.proc.finished.connect(self.__procFinished) |
152 self.proc.finished.connect(self.__procFinished) |
150 self.proc.readyReadStandardOutput.connect(self.__readStdout) |
153 self.proc.readyReadStandardOutput.connect(self.__readStdout) |
159 self.proc.start(cmd, args) |
162 self.proc.start(cmd, args) |
160 procStarted = self.proc.waitForStarted() |
163 procStarted = self.proc.waitForStarted() |
161 if not procStarted: |
164 if not procStarted: |
162 self.buttonBox.setFocus() |
165 self.buttonBox.setFocus() |
163 self.inputGroup.setEnabled(False) |
166 self.inputGroup.setEnabled(False) |
164 E5MessageBox.critical(self, |
167 E5MessageBox.critical( |
|
168 self, |
165 self.trUtf8('Process Generation Error'), |
169 self.trUtf8('Process Generation Error'), |
166 self.trUtf8( |
170 self.trUtf8( |
167 'The process {0} could not be started. ' |
171 'The process {0} could not be started. ' |
168 'Ensure, that it is in the search path.' |
172 'Ensure, that it is in the search path.' |
169 ).format(cmd)) |
173 ).format(cmd)) |
179 It reads the output of the process and appends it to a buffer for |
183 It reads the output of the process and appends it to a buffer for |
180 delayed processing. |
184 delayed processing. |
181 """ |
185 """ |
182 if self.proc is not None: |
186 if self.proc is not None: |
183 out = str(self.proc.readAllStandardOutput(), |
187 out = str(self.proc.readAllStandardOutput(), |
184 Preferences.getSystem("IOEncoding"), |
188 Preferences.getSystem("IOEncoding"), |
185 'replace') |
189 'replace') |
186 self.buffer += out |
190 self.buffer += out |
187 |
191 |
188 def __readStderr(self): |
192 def __readStderr(self): |
189 """ |
193 """ |
190 Private slot to handle the readyReadStandardError signal. |
194 Private slot to handle the readyReadStandardError signal. |
192 It reads the error output of the process and inserts it into the |
196 It reads the error output of the process and inserts it into the |
193 error pane. |
197 error pane. |
194 """ |
198 """ |
195 if self.proc is not None: |
199 if self.proc is not None: |
196 err = str(self.proc.readAllStandardError(), |
200 err = str(self.proc.readAllStandardError(), |
197 Preferences.getSystem("IOEncoding"), |
201 Preferences.getSystem("IOEncoding"), |
198 'replace') |
202 'replace') |
199 self.errorGroup.show() |
203 self.errorGroup.show() |
200 self.errors.insertPlainText(err) |
204 self.errors.insertPlainText(err) |
201 self.errors.ensureCursorVisible() |
205 self.errors.ensureCursorVisible() |
202 |
206 |
203 QCoreApplication.processEvents() |
207 QCoreApplication.processEvents() |