Sat, 15 Dec 2018 17:29:57 +0100
Debugger, Shell: start the shell in the project directory if one is open ([issue290]).
--- a/APIs/Python3/eric6.api Sat Dec 15 16:30:36 2018 +0100 +++ b/APIs/Python3/eric6.api Sat Dec 15 17:29:57 2018 +0100 @@ -485,7 +485,7 @@ eric6.Debugger.DebugServer.DebugServer.signalClientVariable?4(scope, variables) eric6.Debugger.DebugServer.DebugServer.signalClientVariables?4(scope, variables) eric6.Debugger.DebugServer.DebugServer.signalClientWatchConditionError?4(condition) -eric6.Debugger.DebugServer.DebugServer.startClient?4(unplanned=True, clType=None, forProject=False, runInConsole=False, venvName="") +eric6.Debugger.DebugServer.DebugServer.startClient?4(unplanned=True, clType=None, forProject=False, runInConsole=False, venvName="", workingDir=None) eric6.Debugger.DebugServer.DebugServer.unregisterDebuggerInterface?4(interfaceName) eric6.Debugger.DebugServer.DebugServer.utFinished?7 eric6.Debugger.DebugServer.DebugServer.utPrepared?7 @@ -583,8 +583,8 @@ eric6.Debugger.DebuggerInterfaceNone.DebuggerInterfaceNone.remoteWatchpointIgnore?4(cond, count) eric6.Debugger.DebuggerInterfaceNone.DebuggerInterfaceNone.setCallTraceEnabled?4(on) eric6.Debugger.DebuggerInterfaceNone.DebuggerInterfaceNone.shutdown?4() -eric6.Debugger.DebuggerInterfaceNone.DebuggerInterfaceNone.startRemote?4(port, runInConsole, venvName, originalPathString) -eric6.Debugger.DebuggerInterfaceNone.DebuggerInterfaceNone.startRemoteForProject?4(port, runInConsole, venvName, originalPathString) +eric6.Debugger.DebuggerInterfaceNone.DebuggerInterfaceNone.startRemote?4(port, runInConsole, venvName, originalPathString, workingDir=None) +eric6.Debugger.DebuggerInterfaceNone.DebuggerInterfaceNone.startRemoteForProject?4(port, runInConsole, venvName, originalPathString, workingDir=None) eric6.Debugger.DebuggerInterfaceNone.DebuggerInterfaceNone?1(debugServer, passive) eric6.Debugger.DebuggerInterfaceNone.createDebuggerInterfaceNone?4(debugServer, passive) eric6.Debugger.DebuggerInterfaceNone.getRegistryData?4() @@ -625,8 +625,8 @@ eric6.Debugger.DebuggerInterfacePython.DebuggerInterfacePython.remoteWatchpointIgnore?4(cond, count) eric6.Debugger.DebuggerInterfacePython.DebuggerInterfacePython.setCallTraceEnabled?4(on) eric6.Debugger.DebuggerInterfacePython.DebuggerInterfacePython.shutdown?4() -eric6.Debugger.DebuggerInterfacePython.DebuggerInterfacePython.startRemote?4(port, runInConsole, venvName, originalPathString) -eric6.Debugger.DebuggerInterfacePython.DebuggerInterfacePython.startRemoteForProject?4(port, runInConsole, venvName, originalPathString) +eric6.Debugger.DebuggerInterfacePython.DebuggerInterfacePython.startRemote?4(port, runInConsole, venvName, originalPathString, workingDir=None) +eric6.Debugger.DebuggerInterfacePython.DebuggerInterfacePython.startRemoteForProject?4(port, runInConsole, venvName, originalPathString, workingDir=None) eric6.Debugger.DebuggerInterfacePython.DebuggerInterfacePython?1(debugServer, passive, pythonVariant) eric6.Debugger.DebuggerInterfacePython.createDebuggerInterfacePython2?4(debugServer, passive) eric6.Debugger.DebuggerInterfacePython.createDebuggerInterfacePython3?4(debugServer, passive)
--- a/Debugger/DebugServer.py Sat Dec 15 16:30:36 2018 +0100 +++ b/Debugger/DebugServer.py Sat Dec 15 17:29:57 2018 +0100 @@ -460,7 +460,7 @@ 'DebugClient/Type', self.clientType) def startClient(self, unplanned=True, clType=None, forProject=False, - runInConsole=False, venvName=""): + runInConsole=False, venvName="", workingDir=None): """ Public method to start a debug client. @@ -475,6 +475,8 @@ @type bool @keyparam venvName name of the virtual environment to be used @type str + @keyparam workingDir directory to start the debugger client in + @type str """ self.running = False @@ -507,17 +509,17 @@ self.clientProcess, isNetworked, clientInterpreter = \ self.debuggerInterface.startRemote( self.serverPort(), runInConsole, venvName, - self.__originalPathString) + self.__originalPathString, workingDir=workingDir) else: self.clientProcess, isNetworked, clientInterpreter = \ self.debuggerInterface.startRemoteForProject( self.serverPort(), runInConsole, venvName, - self.__originalPathString) + self.__originalPathString, workingDir=workingDir) else: self.clientProcess, isNetworked, clientInterpreter = \ self.debuggerInterface.startRemote( self.serverPort(), runInConsole, venvName, - self.__originalPathString) + self.__originalPathString, workingDir=workingDir) if self.clientProcess: self.clientProcess.readyReadStandardError.connect(
--- a/Debugger/DebuggerInterfaceNone.py Sat Dec 15 16:30:36 2018 +0100 +++ b/Debugger/DebuggerInterfaceNone.py Sat Dec 15 17:29:57 2018 +0100 @@ -38,7 +38,8 @@ # set default values for capabilities of clients self.clientCapabilities = ClientDefaultCapabilities - def startRemote(self, port, runInConsole, venvName, originalPathString): + def startRemote(self, port, runInConsole, venvName, originalPathString, + workingDir=None): """ Public method to start a remote Python interpreter. @@ -51,6 +52,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) @@ -58,7 +61,7 @@ return None, True, "" def startRemoteForProject(self, port, runInConsole, venvName, - originalPathString): + originalPathString, workingDir=None): """ Public method to start a remote Python interpreter for a project. @@ -71,6 +74,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)
--- 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(
--- a/Documentation/Source/eric6.Debugger.DebugServer.html Sat Dec 15 16:30:36 2018 +0100 +++ b/Documentation/Source/eric6.Debugger.DebugServer.html Sat Dec 15 17:29:57 2018 +0100 @@ -1918,7 +1918,7 @@ </dd> </dl><a NAME="DebugServer.startClient" ID="DebugServer.startClient"></a> <h4>DebugServer.startClient</h4> -<b>startClient</b>(<i>unplanned=True, clType=None, forProject=False, runInConsole=False, venvName=""</i>) +<b>startClient</b>(<i>unplanned=True, clType=None, forProject=False, runInConsole=False, venvName="", workingDir=None</i>) <p> Public method to start a debug client. </p><dl> @@ -1938,6 +1938,9 @@ </dd><dt><i>venvName=</i> (str)</dt> <dd> name of the virtual environment to be used +</dd><dt><i>workingDir=</i> (str)</dt> +<dd> +directory to start the debugger client in </dd> </dl><a NAME="DebugServer.unregisterDebuggerInterface" ID="DebugServer.unregisterDebuggerInterface"></a> <h4>DebugServer.unregisterDebuggerInterface</h4>
--- a/Documentation/Source/eric6.Debugger.DebuggerInterfaceNone.html Sat Dec 15 16:30:36 2018 +0100 +++ b/Documentation/Source/eric6.Debugger.DebuggerInterfaceNone.html Sat Dec 15 17:29:57 2018 +0100 @@ -675,7 +675,7 @@ the debug client. (Needed on Win OS) </p><a NAME="DebuggerInterfaceNone.startRemote" ID="DebuggerInterfaceNone.startRemote"></a> <h4>DebuggerInterfaceNone.startRemote</h4> -<b>startRemote</b>(<i>port, runInConsole, venvName, originalPathString</i>) +<b>startRemote</b>(<i>port, runInConsole, venvName, originalPathString, workingDir=None</i>) <p> Public method to start a remote Python interpreter. </p><dl> @@ -692,6 +692,9 @@ </dd><dt><i>originalPathString</i> (str)</dt> <dd> original PATH environment variable +</dd><dt><i>workingDir</i> (str)</dt> +<dd> +directory to start the debugger client in </dd> </dl><dl> <dt>Returns:</dt> @@ -706,7 +709,7 @@ </dd> </dl><a NAME="DebuggerInterfaceNone.startRemoteForProject" ID="DebuggerInterfaceNone.startRemoteForProject"></a> <h4>DebuggerInterfaceNone.startRemoteForProject</h4> -<b>startRemoteForProject</b>(<i>port, runInConsole, venvName, originalPathString</i>) +<b>startRemoteForProject</b>(<i>port, runInConsole, venvName, originalPathString, workingDir=None</i>) <p> Public method to start a remote Python interpreter for a project. </p><dl> @@ -723,6 +726,9 @@ </dd><dt><i>originalPathString</i> (str)</dt> <dd> original PATH environment variable +</dd><dt><i>workingDir</i> (str)</dt> +<dd> +directory to start the debugger client in </dd> </dl><dl> <dt>Returns:</dt>
--- a/Documentation/Source/eric6.Debugger.DebuggerInterfacePython.html Sat Dec 15 16:30:36 2018 +0100 +++ b/Documentation/Source/eric6.Debugger.DebuggerInterfacePython.html Sat Dec 15 17:29:57 2018 +0100 @@ -304,25 +304,32 @@ </dd> </dl><a NAME="DebuggerInterfacePython.__startProcess" ID="DebuggerInterfacePython.__startProcess"></a> <h4>DebuggerInterfacePython.__startProcess</h4> -<b>__startProcess</b>(<i>program, arguments, environment=None</i>) +<b>__startProcess</b>(<i>program, arguments, environment=None, workingDir=None</i>) <p> Private method to start the debugger client process. </p><dl> -<dt><i>program</i></dt> +<dt><i>program</i> (str)</dt> <dd> -name of the executable to start (string) -</dd><dt><i>arguments</i></dt> +name of the executable to start +</dd><dt><i>arguments</i> (list of str)</dt> <dd> -arguments to be passed to the program (list of string) -</dd><dt><i>environment</i></dt> +arguments to be passed to the program +</dd><dt><i>environment</i> (dict of str)</dt> <dd> dictionary of environment settings to pass - (dict of string) +</dd><dt><i>workingDir</i> (str)</dt> +<dd> +directory to start the debugger client in </dd> </dl><dl> <dt>Returns:</dt> <dd> -the process object (QProcess) or None +the process object +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +QProcess or None </dd> </dl><a NAME="DebuggerInterfacePython.__writeJsonCommandToSocket" ID="DebuggerInterfacePython.__writeJsonCommandToSocket"></a> <h4>DebuggerInterfacePython.__writeJsonCommandToSocket</h4> @@ -797,7 +804,7 @@ the debug client. (Needed on Win OS) </p><a NAME="DebuggerInterfacePython.startRemote" ID="DebuggerInterfacePython.startRemote"></a> <h4>DebuggerInterfacePython.startRemote</h4> -<b>startRemote</b>(<i>port, runInConsole, venvName, originalPathString</i>) +<b>startRemote</b>(<i>port, runInConsole, venvName, originalPathString, workingDir=None</i>) <p> Public method to start a remote Python interpreter. </p><dl> @@ -814,6 +821,9 @@ </dd><dt><i>originalPathString</i> (str)</dt> <dd> original PATH environment variable +</dd><dt><i>workingDir</i> (str)</dt> +<dd> +directory to start the debugger client in </dd> </dl><dl> <dt>Returns:</dt> @@ -828,7 +838,7 @@ </dd> </dl><a NAME="DebuggerInterfacePython.startRemoteForProject" ID="DebuggerInterfacePython.startRemoteForProject"></a> <h4>DebuggerInterfacePython.startRemoteForProject</h4> -<b>startRemoteForProject</b>(<i>port, runInConsole, venvName, originalPathString</i>) +<b>startRemoteForProject</b>(<i>port, runInConsole, venvName, originalPathString, workingDir=None</i>) <p> Public method to start a remote Python interpreter for a project. </p><dl> @@ -845,6 +855,9 @@ </dd><dt><i>originalPathString</i> (str)</dt> <dd> original PATH environment variable +</dd><dt><i>workingDir</i> (str)</dt> +<dd> +directory to start the debugger client in </dd> </dl><dl> <dt>Returns:</dt>
--- a/QScintilla/Shell.py Sat Dec 15 16:30:36 2018 +0100 +++ b/QScintilla/Shell.py Sat Dec 15 17:29:57 2018 +0100 @@ -148,6 +148,7 @@ self.__lastSearch = () self.__windowed = windowedVariant self.__currentVenv = "" + self.__currentWorkingDirectory = "" self.linesepRegExp = r"\r\n|\n|\r" @@ -1770,13 +1771,19 @@ venvName = cmdList[1] if venvName == self.tr("Project"): if self.__project.isOpen(): - self.dbs.startClient(False, forProject=True) + self.dbs.startClient( + False, forProject=True, + workingDir=self.__project.getProjectPath()) + self.__currentWorkingDirectory = \ + self.__project.getProjectPath() else: self.dbs.startClient( - False, venvName=self.__currentVenv) + False, venvName=self.__currentVenv, + workingDir=self.__currentWorkingDirectory) # same as reset else: self.dbs.startClient(False, venvName=venvName) + self.__currentWorkingDirectory = "" self.__getBanner() return elif cmd == 'clear': @@ -1787,7 +1794,8 @@ else: cmd = '' elif cmd in ['reset', 'restart']: - self.dbs.startClient(False, venvName=self.__currentVenv) + self.dbs.startClient(False, venvName=self.__currentVenv, + workingDir=self.__currentWorkingDirectory) if self.passive: return else: @@ -1958,7 +1966,8 @@ """ Public slot to handle the 'restart' context menu entry. """ - self.dbs.startClient(False, venvName=self.__currentVenv) + self.dbs.startClient(False, venvName=self.__currentVenv, + workingDir=self.__currentWorkingDirectory) def __startDebugClient(self, action): """ @@ -1969,7 +1978,11 @@ """ venvName = action.text() if venvName == self.tr("Project"): - self.dbs.startClient(False, forProject=True) + if self.__project.isOpen(): + self.__currentWorkingDirectory = \ + self.__project.getProjectPath() + self.dbs.startClient(False, forProject=True, + workingDir=self.__currentWorkingDirectory) else: self.dbs.startClient(False, venvName=venvName) self.__getBanner() @@ -2290,7 +2303,9 @@ Private slot to start the shell for the opened project. """ if Preferences.getProject("RestartShellForProject"): - self.dbs.startClient(False, forProject=True) + self.dbs.startClient(False, forProject=True, + workingDir=self.__project.getProjectPath()) + self.__currentWorkingDirectory = self.__project.getProjectPath() self.__getBanner() def __projectClosed(self):