diff -r 084880ed940c -r c5aab2ede19a Debugger/DebuggerInterfacePython.py --- a/Debugger/DebuggerInterfacePython.py Sat Dec 15 16:30:36 2018 +0100 +++ b/Debugger/DebuggerInterfacePython.py Sat Dec 15 17:29:57 2018 +0100 @@ -109,15 +109,21 @@ else: return fn.replace(self.translateLocal, self.translateRemote) - def __startProcess(self, program, arguments, environment=None): + def __startProcess(self, program, arguments, environment=None, + workingDir=None): """ Private method to start the debugger client process. - @param program name of the executable to start (string) - @param arguments arguments to be passed to the program (list of string) + @param program name of the executable to start + @type str + @param arguments arguments to be passed to the program + @type list of str @param environment dictionary of environment settings to pass - (dict of string) - @return the process object (QProcess) or None + @type dict of str + @param workingDir directory to start the debugger client in + @type str + @return the process object + @rtype QProcess or None """ proc = QProcess() if environment is not None: @@ -126,13 +132,16 @@ env.insert(key, value) proc.setProcessEnvironment(env) args = arguments[:] + if workingDir: + proc.setWorkingDirectory(workingDir) proc.start(program, args) if not proc.waitForStarted(10000): proc = None return proc - def startRemote(self, port, runInConsole, venvName, originalPathString): + def startRemote(self, port, runInConsole, venvName, originalPathString, + workingDir=None): """ Public method to start a remote Python interpreter. @@ -145,6 +154,8 @@ @type str @param originalPathString original PATH environment variable @type str + @param workingDir directory to start the debugger client in + @type str @return client process object, a flag to indicate a network connection and the name of the interpreter in case of a local execution @rtype tuple of (QProcess, bool, str) @@ -210,7 +221,8 @@ [rhost, interpreter, debugClient, noencoding, str(port), redirect, ipaddr] args[0] = Utilities.getExecutablePath(args[0]) - process = self.__startProcess(args[0], args[1:]) + process = self.__startProcess(args[0], args[1:], + workingDir=workingDir) if process is None: E5MessageBox.critical( None, @@ -265,7 +277,8 @@ [interpreter, os.path.abspath(debugClient), noencoding, str(port), '0', ipaddr] args[0] = Utilities.getExecutablePath(args[0]) - process = self.__startProcess(args[0], args[1:], clientEnv) + process = self.__startProcess(args[0], args[1:], clientEnv, + workingDir=workingDir) if process is None: E5MessageBox.critical( None, @@ -278,7 +291,8 @@ process = self.__startProcess( interpreter, [debugClient, noencoding, str(port), redirect, ipaddr], - clientEnv) + clientEnv, + workingDir=workingDir) if process is None: self.__startedVenv = "" E5MessageBox.critical( @@ -292,7 +306,7 @@ return process, self.__isNetworked, interpreter def startRemoteForProject(self, port, runInConsole, venvName, - originalPathString): + originalPathString, workingDir=None): """ Public method to start a remote Python interpreter for a project. @@ -305,6 +319,8 @@ @type str @param originalPathString original PATH environment variable @type str + @param workingDir directory to start the debugger client in + @type str @return client process object, a flag to indicate a network connection and the name of the interpreter in case of a local execution @rtype tuple of (QProcess, bool, str) @@ -356,7 +372,8 @@ [rhost, interpreter, os.path.abspath(debugClient), noencoding, str(port), redirect, ipaddr] args[0] = Utilities.getExecutablePath(args[0]) - process = self.__startProcess(args[0], args[1:]) + process = self.__startProcess(args[0], args[1:], + workingDir=workingDir) if process is None: E5MessageBox.critical( None, @@ -411,7 +428,8 @@ [interpreter, os.path.abspath(debugClient), noencoding, str(port), '0', ipaddr] args[0] = Utilities.getExecutablePath(args[0]) - process = self.__startProcess(args[0], args[1:], clientEnv) + process = self.__startProcess(args[0], args[1:], clientEnv, + workingDir=workingDir) if process is None: E5MessageBox.critical( None, @@ -424,7 +442,8 @@ process = self.__startProcess( interpreter, [debugClient, noencoding, str(port), redirect, ipaddr], - clientEnv) + clientEnv, + workingDir=workingDir) if process is None: self.__startedVenv = "" E5MessageBox.critical(