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 import os |
10 import os |
11 |
11 |
12 from PyQt4.QtCore import QTimer, QProcess, pyqtSlot, Qt |
12 from PyQt4.QtCore import QTimer, QProcess, pyqtSlot, Qt, QProcessEnvironment |
13 from PyQt4.QtGui import QLineEdit, QDialog, QDialogButtonBox |
13 from PyQt4.QtGui import QLineEdit, QDialog, QDialogButtonBox |
14 |
14 |
15 from E5Gui import E5MessageBox |
15 from E5Gui import E5MessageBox |
16 |
16 |
17 from .Ui_SvnDialog import Ui_SvnDialog |
17 from .Ui_SvnDialog import Ui_SvnDialog |
94 @param exitStatus exit status of the process (QProcess.ExitStatus) |
94 @param exitStatus exit status of the process (QProcess.ExitStatus) |
95 """ |
95 """ |
96 self.normal = (exitStatus == QProcess.NormalExit) and (exitCode == 0) |
96 self.normal = (exitStatus == QProcess.NormalExit) and (exitCode == 0) |
97 self.__finish() |
97 self.__finish() |
98 |
98 |
99 def startProcess(self, args, workingDir=None): |
99 def startProcess(self, args, workingDir=None, setLanguage=False): |
100 """ |
100 """ |
101 Public slot used to start the process. |
101 Public slot used to start the process. |
102 |
102 |
103 @param args list of arguments for the process (list of strings) |
103 @param args list of arguments for the process (list of strings) |
104 @param workingDir working directory for the process (string) |
104 @param workingDir working directory for the process (string) |
|
105 @param setLanguage flag indicating to set the language to "C" (boolean) |
105 @return flag indicating a successful start of the process |
106 @return flag indicating a successful start of the process |
106 """ |
107 """ |
107 self.errorGroup.hide() |
108 self.errorGroup.hide() |
108 self.normal = False |
109 self.normal = False |
109 self.intercept = False |
110 self.intercept = False |
110 |
111 |
111 self.__hasAddOrDelete = False |
112 self.__hasAddOrDelete = False |
112 |
113 |
113 self.proc = QProcess() |
114 self.proc = QProcess() |
|
115 if setLanguage: |
|
116 env = QProcessEnvironment.systemEnvironment() |
|
117 env.insert("LANG", "C") |
|
118 self.proc.setProcessEnvironment(env) |
114 nargs = [] |
119 nargs = [] |
115 lastWasPwd = False |
120 lastWasPwd = False |
116 for arg in args: |
121 for arg in args: |
117 if lastWasPwd: |
122 if lastWasPwd: |
118 lastWasPwd = True |
123 lastWasPwd = True |
173 # check the output |
178 # check the output |
174 for l in s.split(os.linesep): |
179 for l in s.split(os.linesep): |
175 if '.e4p' in l: |
180 if '.e4p' in l: |
176 self.__hasAddOrDelete = True |
181 self.__hasAddOrDelete = True |
177 break |
182 break |
178 if l and l[0].strip() in ['A', 'D']: |
183 if l and l[0:2].strip() in ['A', 'D']: |
179 self.__hasAddOrDelete = True |
184 self.__hasAddOrDelete = True |
180 break |
185 break |
181 |
186 |
182 def __readStderr(self): |
187 def __readStderr(self): |
183 """ |
188 """ |