7 Module implementing a dialog starting a process and showing its output. |
7 Module implementing a dialog starting a process and showing its output. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 try: |
11 try: |
12 str = unicode # __IGNORE_WARNING__ |
12 str = unicode |
13 except (NameError): |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 import os |
16 import os |
17 |
17 |
18 from PyQt4.QtCore import QProcess, QTimer, pyqtSlot, Qt, QCoreApplication |
18 from PyQt4.QtCore import QProcess, QTimer, pyqtSlot, Qt, QCoreApplication |
31 |
31 |
32 It starts a QProcess and displays a dialog that |
32 It starts a QProcess and displays a dialog that |
33 shows the output of the process. The dialog is modal, |
33 shows the output of the process. The dialog is modal, |
34 which causes a synchronized execution of the process. |
34 which causes a synchronized execution of the process. |
35 """ |
35 """ |
36 def __init__(self, text, hg=None, parent=None): |
36 def __init__(self, text, hg=None, useClient=True, parent=None): |
37 """ |
37 """ |
38 Constructor |
38 Constructor |
39 |
39 |
40 @param text text to be shown by the label (string) |
40 @param text text to be shown by the label (string) |
41 @param hg reference to the Mercurial interface object (Hg) |
41 @param hg reference to the Mercurial interface object (Hg) |
|
42 @param useClient flag indicating to use the command server client |
|
43 if possible (boolean) |
42 @param parent parent widget (QWidget) |
44 @param parent parent widget (QWidget) |
43 """ |
45 """ |
44 super(HgDialog, self).__init__(parent) |
46 super(HgDialog, self).__init__(parent) |
45 self.setupUi(self) |
47 self.setupUi(self) |
46 |
48 |
122 self.intercept = False |
128 self.intercept = False |
123 |
129 |
124 self.__hasAddOrDelete = False |
130 self.__hasAddOrDelete = False |
125 if args[0] in ["fetch", "qpush", "qpop", "qgoto", "rebase", |
131 if args[0] in ["fetch", "qpush", "qpop", "qgoto", "rebase", |
126 "transplant", "update", "import", "revert", |
132 "transplant", "update", "import", "revert", |
127 "graft"] or \ |
133 "graft", "shelve", "unshelve"] or \ |
128 (args[0] in ["pull", "unbundle"] and |
134 (args[0] in ["pull", "unbundle"] and |
129 ("--update" in args[1:] or "--rebase" in args[1:])): |
135 ("--update" in args[1:] or "--rebase" in args[1:])): |
130 self.__updateCommand = True |
136 self.__updateCommand = True |
131 else: |
137 else: |
132 self.__updateCommand = False |
138 self.__updateCommand = False |
149 if not procStarted: |
155 if not procStarted: |
150 self.buttonBox.setFocus() |
156 self.buttonBox.setFocus() |
151 self.inputGroup.setEnabled(False) |
157 self.inputGroup.setEnabled(False) |
152 E5MessageBox.critical( |
158 E5MessageBox.critical( |
153 self, |
159 self, |
154 self.trUtf8('Process Generation Error'), |
160 self.tr('Process Generation Error'), |
155 self.trUtf8( |
161 self.tr( |
156 'The process {0} could not be started. ' |
162 'The process {0} could not be started. ' |
157 'Ensure, that it is in the search path.' |
163 'Ensure, that it is in the search path.' |
158 ).format('hg')) |
164 ).format('hg')) |
159 else: |
165 else: |
160 self.inputGroup.setEnabled(True) |
166 self.inputGroup.setEnabled(True) |
202 It reads the output of the process, formats it and inserts it into |
208 It reads the output of the process, formats it and inserts it into |
203 the contents pane. |
209 the contents pane. |
204 """ |
210 """ |
205 if self.proc is not None: |
211 if self.proc is not None: |
206 s = str(self.proc.readAllStandardOutput(), |
212 s = str(self.proc.readAllStandardOutput(), |
207 Preferences.getSystem("IOEncoding"), |
213 self.vcs.getEncoding(), |
208 'replace') |
214 'replace') |
209 self.__showOutput(s) |
215 self.__showOutput(s) |
210 |
216 |
211 def __showOutput(self, out): |
217 def __showOutput(self, out): |
212 """ |
218 """ |
233 It reads the error output of the process and inserts it into the |
239 It reads the error output of the process and inserts it into the |
234 error pane. |
240 error pane. |
235 """ |
241 """ |
236 if self.proc is not None: |
242 if self.proc is not None: |
237 s = str(self.proc.readAllStandardError(), |
243 s = str(self.proc.readAllStandardError(), |
238 Preferences.getSystem("IOEncoding"), |
244 self.vcs.getEncoding(), |
239 'replace') |
245 'replace') |
240 self.__showError(s) |
246 self.__showError(s) |
241 |
247 |
242 def __showError(self, out): |
248 def __showError(self, out): |
243 """ |
249 """ |