25 |
25 |
26 It starts a QProcess and displays a dialog that |
26 It starts a QProcess and displays a dialog that |
27 shows the output of the process. The dialog is modal, |
27 shows the output of the process. The dialog is modal, |
28 which causes a synchronized execution of the process. |
28 which causes a synchronized execution of the process. |
29 """ |
29 """ |
30 def __init__(self, text, parent=None): |
30 def __init__(self, text, hg=None, parent=None): |
31 """ |
31 """ |
32 Constructor |
32 Constructor |
33 |
33 |
34 @param text text to be shown by the label (string) |
34 @param text text to be shown by the label (string) |
|
35 @param hg reference to the Mercurial interface object (Hg) |
35 @param parent parent widget (QWidget) |
36 @param parent parent widget (QWidget) |
36 """ |
37 """ |
37 super().__init__(parent) |
38 super().__init__(parent) |
38 self.setupUi(self) |
39 self.setupUi(self) |
39 |
40 |
112 ("--update" in args[1:] or "--rebase" in args[1:])): |
114 ("--update" in args[1:] or "--rebase" in args[1:])): |
113 self.__updateCommand = True |
115 self.__updateCommand = True |
114 else: |
116 else: |
115 self.__updateCommand = False |
117 self.__updateCommand = False |
116 |
118 |
117 self.proc = QProcess() |
|
118 |
|
119 if showArgs: |
119 if showArgs: |
120 self.resultbox.append(' '.join(args)) |
120 self.resultbox.append(' '.join(args)) |
121 self.resultbox.append('') |
121 self.resultbox.append('') |
122 |
122 |
123 self.proc.finished.connect(self.__procFinished) |
123 if self.__hgClient is None: |
124 self.proc.readyReadStandardOutput.connect(self.__readStdout) |
124 self.proc = QProcess() |
125 self.proc.readyReadStandardError.connect(self.__readStderr) |
125 |
126 |
126 self.proc.finished.connect(self.__procFinished) |
127 if workingDir: |
127 self.proc.readyReadStandardOutput.connect(self.__readStdout) |
128 self.proc.setWorkingDirectory(workingDir) |
128 self.proc.readyReadStandardError.connect(self.__readStderr) |
129 self.proc.start('hg', args) |
129 |
130 procStarted = self.proc.waitForStarted() |
130 if workingDir: |
131 if not procStarted: |
131 self.proc.setWorkingDirectory(workingDir) |
132 self.buttonBox.setFocus() |
132 self.proc.start('hg', args) |
133 self.inputGroup.setEnabled(False) |
133 procStarted = self.proc.waitForStarted() |
134 E5MessageBox.critical(self, |
134 if not procStarted: |
135 self.trUtf8('Process Generation Error'), |
135 self.buttonBox.setFocus() |
136 self.trUtf8( |
136 self.inputGroup.setEnabled(False) |
137 'The process {0} could not be started. ' |
137 E5MessageBox.critical(self, |
138 'Ensure, that it is in the search path.' |
138 self.trUtf8('Process Generation Error'), |
139 ).format('hg')) |
139 self.trUtf8( |
140 else: |
140 'The process {0} could not be started. ' |
141 self.inputGroup.setEnabled(True) |
141 'Ensure, that it is in the search path.' |
142 self.inputGroup.show() |
142 ).format('hg')) |
143 return procStarted |
143 else: |
|
144 self.inputGroup.setEnabled(True) |
|
145 self.inputGroup.show() |
|
146 return procStarted |
|
147 else: |
|
148 out, err = self.__hgClient.runcommand(args) |
|
149 |
|
150 if out: |
|
151 self.__showOutput(out) |
|
152 if err: |
|
153 self.__showError(err) |
|
154 |
|
155 self.normal = True |
|
156 |
|
157 self.__finish() |
|
158 |
|
159 return True |
144 |
160 |
145 def normalExit(self): |
161 def normalExit(self): |
146 """ |
162 """ |
147 Public method to check for a normal process termination. |
163 Public method to check for a normal process termination. |
148 |
164 |
168 """ |
184 """ |
169 if self.proc is not None: |
185 if self.proc is not None: |
170 s = str(self.proc.readAllStandardOutput(), |
186 s = str(self.proc.readAllStandardOutput(), |
171 Preferences.getSystem("IOEncoding"), |
187 Preferences.getSystem("IOEncoding"), |
172 'replace') |
188 'replace') |
173 self.resultbox.insertPlainText(s) |
189 self.__showOutput(s) |
174 self.resultbox.ensureCursorVisible() |
190 |
175 |
191 def __showOutput(self, out): |
176 # check for a changed project file |
192 """ |
177 if self.__updateCommand: |
193 Private slot to show some output. |
178 for line in s.splitlines(): |
194 |
179 if '.e4p' in line: |
195 @param out output to be shown (string) |
180 self.__hasAddOrDelete = True |
196 """ |
181 break |
197 self.resultbox.insertPlainText(out) |
|
198 self.resultbox.ensureCursorVisible() |
|
199 |
|
200 # check for a changed project file |
|
201 if self.__updateCommand: |
|
202 for line in out.splitlines(): |
|
203 if '.e4p' in line: |
|
204 self.__hasAddOrDelete = True |
|
205 break |
182 |
206 |
183 QCoreApplication.processEvents() |
207 QCoreApplication.processEvents() |
184 |
208 |
185 def __readStderr(self): |
209 def __readStderr(self): |
186 """ |
210 """ |
188 |
212 |
189 It reads the error output of the process and inserts it into the |
213 It reads the error output of the process and inserts it into the |
190 error pane. |
214 error pane. |
191 """ |
215 """ |
192 if self.proc is not None: |
216 if self.proc is not None: |
193 self.errorGroup.show() |
|
194 s = str(self.proc.readAllStandardError(), |
217 s = str(self.proc.readAllStandardError(), |
195 Preferences.getSystem("IOEncoding"), |
218 Preferences.getSystem("IOEncoding"), |
196 'replace') |
219 'replace') |
197 self.errors.insertPlainText(s) |
220 self.__showError(s) |
198 self.errors.ensureCursorVisible() |
221 |
|
222 def __showError(self, out): |
|
223 """ |
|
224 Private slot to show some error. |
|
225 |
|
226 @param out error to be shown (string) |
|
227 """ |
|
228 self.errorGroup.show() |
|
229 self.errors.insertPlainText(out) |
|
230 self.errors.ensureCursorVisible() |
199 |
231 |
200 QCoreApplication.processEvents() |
232 QCoreApplication.processEvents() |
201 |
233 |
202 def on_passwordCheckBox_toggled(self, isOn): |
234 def on_passwordCheckBox_toggled(self, isOn): |
203 """ |
235 """ |