215 @param clientArgs list of arguments for the client |
215 @param clientArgs list of arguments for the client |
216 @param idString id of the client to be started |
216 @param idString id of the client to be started |
217 @type str |
217 @type str |
218 @param environment dictionary of environment settings to pass |
218 @param environment dictionary of environment settings to pass |
219 @type dict |
219 @type dict |
220 @return flag indicating a successful client start |
220 @return flag indicating a successful client start and the exit code |
221 @rtype bool |
221 in case of an issue |
|
222 @rtype bool, int |
222 """ |
223 """ |
223 if interpreter == "" or not Utilities.isinpath(interpreter): |
224 if interpreter == "" or not Utilities.isinpath(interpreter): |
224 return False |
225 return False |
|
226 |
|
227 exitCode = None |
225 |
228 |
226 proc = QProcess() |
229 proc = QProcess() |
227 proc.setProcessChannelMode( |
230 proc.setProcessChannelMode( |
228 QProcess.ProcessChannelMode.ForwardedChannels) |
231 QProcess.ProcessChannelMode.ForwardedChannels) |
229 if environment is not None: |
232 if environment is not None: |
251 ): |
254 ): |
252 # Give the event loop the chance to process the new |
255 # Give the event loop the chance to process the new |
253 # connection of the client (= slow start). |
256 # connection of the client (= slow start). |
254 QCoreApplication.processEvents( |
257 QCoreApplication.processEvents( |
255 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) |
258 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) |
|
259 |
|
260 # check if client exited prematurely |
|
261 state = proc.state() |
|
262 if state == QProcess.ProcessState.NotRunning: |
|
263 exitCode = proc.exitCode() |
|
264 proc = None |
|
265 self.__clientProcesses[idString] = None |
|
266 break |
256 else: |
267 else: |
257 self.__clientProcess = proc |
268 self.__clientProcess = proc |
258 |
269 |
259 return proc is not None |
270 return proc is not None, exitCode |
260 |
271 |
261 def stopClient(self, idString=""): |
272 def stopClient(self, idString=""): |
262 """ |
273 """ |
263 Public method to stop a client process. |
274 Public method to stop a client process. |
264 |
275 |