Debugger/DebuggerInterfacePython.py

branch
maintenance
changeset 6646
51eefa621de4
parent 6645
ad476851d7e0
child 6716
1c9d3b369ea8
--- a/Debugger/DebuggerInterfacePython.py	Sat Dec 01 11:45:24 2018 +0100
+++ b/Debugger/DebuggerInterfacePython.py	Thu Jan 10 14:22:59 2019 +0100
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2009 - 2018 Detlev Offenbach <detlev@die-offenbachs.de>
+# Copyright (c) 2009 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
 #
 
 """
@@ -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(
@@ -978,7 +997,7 @@
                         """ this issue with the received data to the"""
                         """ eric bugs email address.</p>"""
                         """<p>Error: {0}</p>"""
-                        """<p>Data:<br/>{0}</p>""").format(
+                        """<p>Data:<br/>{1}</p>""").format(
                     str(err), Utilities.html_encode(jsonStr.strip())),
                 E5MessageBox.StandardButtons(
                     E5MessageBox.Ok))

eric ide

mercurial