Improved the handling of debug client exits. jsonrpc

Sat, 03 Sep 2016 19:00:12 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 03 Sep 2016 19:00:12 +0200
branch
jsonrpc
changeset 5136
b1dde2dc14bd
parent 5135
04905a8681dc
child 5137
089401c122c5

Improved the handling of debug client exits.

Debugger/DebugServer.py file | annotate | diff | comparison | revisions
Debugger/DebugUI.py file | annotate | diff | comparison | revisions
Debugger/DebuggerInterfacePython2.py file | annotate | diff | comparison | revisions
Debugger/DebuggerInterfacePython3.py file | annotate | diff | comparison | revisions
--- a/Debugger/DebugServer.py	Sat Sep 03 18:42:02 2016 +0200
+++ b/Debugger/DebugServer.py	Sat Sep 03 19:00:12 2016 +0200
@@ -133,7 +133,7 @@
     clientException = pyqtSignal(str, str, list)
     clientSyntaxError = pyqtSignal(str, str, int, int)
     clientSignal = pyqtSignal(str, str, int, str, str)
-    clientExit = pyqtSignal(int)
+    clientExit = pyqtSignal(int, str)
     clientBreakConditionError = pyqtSignal(str, int)
     clientWatchConditionError = pyqtSignal(str)
     clientRawInput = pyqtSignal(str, bool)
@@ -1312,15 +1312,18 @@
             self.clientSignal.emit(message, filename, lineNo,
                                    funcName, funcArgs)
         
-    def signalClientExit(self, status):
+    def signalClientExit(self, status, message=""):
         """
         Public method to process the client exit status.
         
-        @param status exit code as a string (string)
+        @param status exit code
+        @type int
+        @param message message sent with the exit
+        @type str
         """
         if self.passive:
             self.__passiveShutDown()
-        self.clientExit.emit(int(status))
+        self.clientExit.emit(int(status), message)
         if Preferences.getDebugger("AutomaticReset") or (self.running and
                                                          not self.debugging):
             self.startClient(False)
--- a/Debugger/DebugUI.py	Sat Sep 03 18:42:02 2016 +0200
+++ b/Debugger/DebugUI.py	Sat Sep 03 19:00:12 2016 +0200
@@ -979,7 +979,7 @@
 
         self.debugActGrp.setEnabled(True)
         
-    def __clientExit(self, status):
+    def __clientExit(self, status, message):
         """
         Private method to handle the debugged program terminating.
         
@@ -990,28 +990,38 @@
         self.__resetUI()
         
         if not Preferences.getDebugger("SuppressClientExit") or status != 0:
+            if message:
+                info = self.tr("<p>Message: {0}</p>").format(
+                    Utilities.html_uencode(message))
+            else:
+                info = ""
             if self.ui.currentProg is None:
                 E5MessageBox.information(
                     self.ui, Program,
                     self.tr('<p>The program has terminated with an exit'
-                            ' status of {0}.</p>').format(status))
+                            ' status of {0}.</p>{1}').format(status, info))
             else:
                 E5MessageBox.information(
                     self.ui, Program,
                     self.tr('<p><b>{0}</b> has terminated with an exit'
-                            ' status of {1}.</p>')
+                            ' status of {1}.</p>{2}')
                         .format(Utilities.normabspath(self.ui.currentProg),
-                                status))
+                                status, info))
         else:
+            if message:
+                info = self.tr("Message: {0}").format(
+                    Utilities.html_uencode(message))
+            else:
+                info = ""
             if self.ui.notificationsEnabled():
                 if self.ui.currentProg is None:
                     msg = self.tr('The program has terminated with an exit'
-                                  ' status of {0}.').format(status)
+                                  ' status of {0}.\n{1}').format(status, info)
                 else:
                     msg = self.tr('"{0}" has terminated with an exit'
-                                  ' status of {1}.')\
+                                  ' status of {1}.\n{2}')\
                         .format(os.path.basename(self.ui.currentProg),
-                                status)
+                                status, info)
                 self.ui.showNotification(
                     UI.PixmapCache.getPixmap("debug48.png"),
                     self.tr("Program terminated"), msg)
@@ -1019,13 +1029,13 @@
                 if self.ui.currentProg is None:
                     self.appendStdout.emit(
                         self.tr('The program has terminated with an exit'
-                                ' status of {0}.\n').format(status))
+                                ' status of {0}.\n{1}\n').format(status, info))
                 else:
                     self.appendStdout.emit(
                         self.tr('"{0}" has terminated with an exit'
-                                ' status of {1}.\n')
+                                ' status of {1}.\n{2}\n')
                             .format(Utilities.normabspath(self.ui.currentProg),
-                                    status))
+                                    status, info))
 
     def __clientSyntaxError(self, message, filename, lineNo, characterNo):
         """
--- a/Debugger/DebuggerInterfacePython2.py	Sat Sep 03 18:42:02 2016 +0200
+++ b/Debugger/DebuggerInterfacePython2.py	Sat Sep 03 19:00:12 2016 +0200
@@ -970,10 +970,8 @@
         
         elif method == "ResponseExit":
             self.__scriptName = ""
-            # TODO: combine these into signalClientExit
-            self.debugServer.signalClientExit(params["status"])
-            if params["message"]:
-                self.debugServer.signalClientOutput(params["message"])
+            self.debugServer.signalClientExit(
+                params["status"], params["message"])
         
         elif method == "PassiveStartup":
             self.debugServer.passiveStartUp(
--- a/Debugger/DebuggerInterfacePython3.py	Sat Sep 03 18:42:02 2016 +0200
+++ b/Debugger/DebuggerInterfacePython3.py	Sat Sep 03 19:00:12 2016 +0200
@@ -970,10 +970,8 @@
         
         elif method == "ResponseExit":
             self.__scriptName = ""
-            # TODO: combine these into signalClientExit
-            self.debugServer.signalClientExit(params["status"])
-            if params["message"]:
-                self.debugServer.signalClientOutput(params["message"])
+            self.debugServer.signalClientExit(
+                params["status"], params["message"])
         
         elif method == "PassiveStartup":
             self.debugServer.passiveStartUp(

eric ide

mercurial