Integrated the 'run', 'profile' and 'coverage' and the restart debugging functions. server

Mon, 12 Feb 2024 18:12:41 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Feb 2024 18:12:41 +0100
branch
server
changeset 10564
0de57f082daa
parent 10563
b4b47c1a02ba
child 10565
3583a10ce4d4

Integrated the 'run', 'profile' and 'coverage' and the restart debugging functions.

src/eric7/Debugger/DebugServer.py file | annotate | diff | comparison | revisions
src/eric7/Debugger/DebugUI.py file | annotate | diff | comparison | revisions
src/eric7/Debugger/DebuggerInterfacePython.py file | annotate | diff | comparison | revisions
--- a/src/eric7/Debugger/DebugServer.py	Mon Feb 12 18:09:53 2024 +0100
+++ b/src/eric7/Debugger/DebugServer.py	Mon Feb 12 18:12:41 2024 +0100
@@ -615,7 +615,12 @@
                     self.remoteBanner()
             elif startRemote:
                 self.__ericServerDebugging = True
-                self.remoteBanner()
+                if self.lastClientType != self.clientType:
+                    self.lastClientType = self.clientType
+                    self.remoteBanner()
+                elif self.__autoClearShell:
+                    self.__autoClearShell = False
+                    self.remoteBanner()
             else:
                 if clType and self.lastClientType:
                     self.__setClientType(self.lastClientType)
@@ -1206,6 +1211,7 @@
             runInConsole=runInConsole,
             venvName=venvName,
             configOverride=configOverride,
+            startRemote=FileSystemUtilities.isRemoteFileName(fn),
         )
 
         self.remoteEnvironment(env)
--- a/src/eric7/Debugger/DebugUI.py	Mon Feb 12 18:09:53 2024 +0100
+++ b/src/eric7/Debugger/DebugUI.py	Mon Feb 12 18:12:41 2024 +0100
@@ -2048,6 +2048,13 @@
                     self.clientType = editor.determineFileType()
                 self.lastStartAction = 5
 
+            if (
+                FileSystemUtilities.isRemoteFileName(fn)
+                and not self.ui.isEricServerConnected()
+            ):
+                self.__showNotConnectedWarning(title=cap)
+                return
+
             # save the filename for use by the restart method
             self.lastDebuggedFile = fn
             self.restartAct.setEnabled(True)
@@ -2243,6 +2250,13 @@
                     self.clientType = editor.determineFileType()
                 self.lastStartAction = 7
 
+            if (
+                FileSystemUtilities.isRemoteFileName(fn)
+                and not self.ui.isEricServerConnected()
+            ):
+                self.__showNotConnectedWarning(title=cap)
+                return
+
             # save the filename for use by the restart method
             self.lastDebuggedFile = fn
             self.restartAct.setEnabled(True)
@@ -2433,6 +2447,13 @@
                     self.clientType = editor.determineFileType()
                 self.lastStartAction = 3
 
+            if (
+                FileSystemUtilities.isRemoteFileName(fn)
+                and not self.ui.isEricServerConnected()
+            ):
+                self.__showNotConnectedWarning(title=cap)
+                return
+
             # save the filename for use by the restart method
             self.lastDebuggedFile = fn
             self.restartAct.setEnabled(True)
@@ -2515,8 +2536,8 @@
         @param debugProject flag indicating debugging the current project
             (True) or script (False)
         @type bool
-        @param script name of a script (optional)
-        @type str
+        @param script name of a script (defaults to "")
+        @type str (optional)
         """
         from .StartDialog import StartDialog, StartDialogMode
 
@@ -2636,6 +2657,13 @@
                     self.clientType = editor.determineFileType()
                 self.lastStartAction = 1
 
+            if (
+                FileSystemUtilities.isRemoteFileName(fn)
+                and not self.ui.isEricServerConnected()
+            ):
+                self.__showNotConnectedWarning(title=cap)
+                return
+
             # save the filename for use by the restart method
             self.lastDebuggedFile = fn
             self.restartAct.setEnabled(True)
@@ -2828,6 +2856,13 @@
         self.viewmanager.unhighlight()
 
         if not doNotStart:
+            if (
+                FileSystemUtilities.isRemoteFileName(fn)
+                and not self.ui.isEricServerConnected()
+            ):
+                self.__showNotConnectedWarning(title=self.tr("Restart"))
+                return
+
             if forProject and self.project.getProjectType() in ["E7Plugin"]:
                 argv = '--plugin="{0}" {1}'.format(fn, argv)
                 fn = ""  # script name of the eric IDE is set in debug client
@@ -3169,3 +3204,20 @@
         @rtype str
         """
         return self.debugServer.getProjectEnvironmentString()
+
+    def __showNotConnectedWarning(self, title):
+        """
+        Private method to show a warning about a not connected eric-ide server.
+
+        @param title title for the dialog
+        @type str
+        """
+        EricMessageBox.warning(
+            None,
+            title,
+            self.tr(
+                "<p>The selected file is located on an eric-ide server but no such"
+                " server is connected. Aborting...</p>"
+            ),
+        )
+        
--- a/src/eric7/Debugger/DebuggerInterfacePython.py	Mon Feb 12 18:09:53 2024 +0100
+++ b/src/eric7/Debugger/DebuggerInterfacePython.py	Mon Feb 12 18:12:41 2024 +0100
@@ -259,9 +259,7 @@
 
         self.__inShutdown = False
 
-        self.__ericServerDebuggerInterface.stopClient()
         self.__ericServerDebugging = False
-        self.__mainDebugger = None
 
         redirect = (
             str(configOverride["redirect"])
@@ -544,9 +542,7 @@
 
         self.__inShutdown = False
 
-        self.__ericServerDebuggerInterface.stopClient()
         self.__ericServerDebugging = False
-        self.__mainDebugger = None
 
         if project.getDebugProperty("REMOTEDEBUGGER"):
             # remote debugging code
@@ -794,9 +790,9 @@
         with contextlib.suppress(RuntimeError):
             # debug server object might have been deleted already
             # ignore this
-            self.debugServer.signalLastClientExited()
             self.__autoContinued.clear()
             if not self.__inShutdown:
+                self.debugServer.signalLastClientExited()
                 self.debugServer.startClient()
 
     def getDebuggerIds(self):
@@ -846,6 +842,8 @@
             sock = self.__pendingConnections.pop()
             self.__shutdownSocket(sock)
 
+        self.__ericServerDebuggerInterface.stopClient()
+
         # reinitialize
         self.__commandQueue.clear()
 
@@ -878,7 +876,7 @@
         @return flag indicating the connection status
         @rtype bool
         """
-        return bool(self.__connections)
+        return bool(self.__connections) or self.__ericServerDebugging
 
     def remoteEnvironment(self, env):
         """
@@ -956,10 +954,13 @@
         @param wd working directory for the program
         @type str
         """
-        self.__scriptName = os.path.abspath(fn)
+        if FileSystemUtilities.isPlainFileName(fn):
+            fn = os.path.abspath(fn)
+
+        self.__scriptName = fn
 
         wd = self.translate(wd, False)
-        fn = self.translate(os.path.abspath(fn), False)
+        fn = self.translate(fn, False)
         self.__sendJsonCommand(
             "RequestRun",
             {
@@ -984,10 +985,13 @@
             cleared first
         @type bool
         """
-        self.__scriptName = os.path.abspath(fn)
+        if FileSystemUtilities.isPlainFileName(fn):
+            fn = os.path.abspath(fn)
+
+        self.__scriptName = fn
 
         wd = self.translate(wd, False)
-        fn = self.translate(os.path.abspath(fn), False)
+        fn = self.translate(fn, False)
         self.__sendJsonCommand(
             "RequestCoverage",
             {
@@ -1013,10 +1017,13 @@
             first
         @type bool
         """
-        self.__scriptName = os.path.abspath(fn)
+        if FileSystemUtilities.isPlainFileName(fn):
+            fn = os.path.abspath(fn)
+
+        self.__scriptName = fn
 
         wd = self.translate(wd, False)
-        fn = self.translate(os.path.abspath(fn), False)
+        fn = self.translate(fn, False)
         self.__sendJsonCommand(
             "RequestProfile",
             {
@@ -1699,6 +1706,7 @@
             self.debugServer.signalClientRawInput(
                 params["prompt"], params["echo"], params["debuggerId"]
             )
+            pass
 
         elif method == "ResponseBPConditionError":
             fn = self.translate(params["filename"], True)
@@ -1823,7 +1831,8 @@
             if debuggerId and debuggerId in self.__connections:
                 sock = self.__connections[debuggerId]
             elif sock is None and self.__mainDebugger is not None:
-                sock = self.__connections[self.__mainDebugger]
+                with contextlib.suppress(KeyError):
+                    sock = self.__connections[self.__mainDebugger]
             if sock is not None:
                 self.__writeJsonCommandToSocket(jsonStr, sock)
             else:

eric ide

mercurial