Sun, 16 Feb 2020 16:14:25 +0100
Continued with the multiprocess debugger.
--- a/eric6/DebugClients/Python/DebugBase.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/DebugClients/Python/DebugBase.py Sun Feb 16 16:14:25 2020 +0100 @@ -434,12 +434,14 @@ @param cmd command / code to execute under debugger control @type str or CodeType - @keyparam globalsDict dictionary of global variables for cmd + @param globalsDict dictionary of global variables for cmd + @type dict + @param localsDict dictionary of local variables for cmd @type dict - @keyparam localsDict dictionary of local variables for cmd - @type dict - @keyparam debug flag if command should run under debugger control + @param debug flag if command should run under debugger control @type bool + @return exit code of the program + @rtype int """ if globalsDict is None: import __main__ @@ -462,6 +464,7 @@ exec(cmd, globalsDict, localsDict) atexit._run_exitfuncs() self._dbgClient.progTerminated(0) + exitcode = 0 except SystemExit: atexit._run_exitfuncs() excinfo = sys.exc_info() @@ -470,9 +473,11 @@ except Exception: excinfo = sys.exc_info() self.user_exception(excinfo, True) + exitcode = 242 finally: self.quitting = True sys.settrace(None) + return exitcode def _set_stopinfo(self, stopframe, returnframe): """ @@ -981,6 +986,9 @@ elif isinstance(code, int): exitcode = code message = "" + elif code is None: + exitcode = 0 + message = "" else: exitcode = 1 message = str(code)
--- a/eric6/DebugClients/Python/DebugClientBase.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/DebugClients/Python/DebugClientBase.py Sun Feb 16 16:14:25 2020 +0100 @@ -1502,13 +1502,17 @@ elif not isinstance(status, int): message = str(status) status = 1 - + if message is None: + message = "" + if self.running: self.set_quit() + program = self.running self.running = None self.sendJsonCommand("ResponseExit", { "status": status, "message": message, + "program": program, }) # reset coding @@ -2164,7 +2168,6 @@ res = self.mainThread.run(code, self.debugMod.__dict__, debug=True) else: res = 42 # should not happen - self.progTerminated(res) return res def run_call(self, scriptname, func, *args): @@ -2208,6 +2211,7 @@ time.sleep(3) return None + # TODO: add support for the '-m' python invocation => '--module' def main(self): """ Public method implementing the main method.
--- a/eric6/DebugClients/Python/DebugUtilities.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/DebugClients/Python/DebugUtilities.py Sun Feb 16 16:14:25 2020 +0100 @@ -213,6 +213,9 @@ @return flag indicating a Python interpreter or program @rtype bool """ + if not program: + return False + prog = os.path.basename(program).lower() for pyname in PYTHON_NAMES: if pyname in prog: @@ -285,7 +288,6 @@ interpreterArgs.append(args.pop(0)) else: break - print(interpreter, interpreterArgs, args) (wd, host, port, exceptions, tracePython, redirect, noencoding ) = debugClient.startOptions[:7]
--- a/eric6/Debugger/CallTraceViewer.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/Debugger/CallTraceViewer.py Sun Feb 16 16:14:25 2020 +0100 @@ -300,11 +300,13 @@ """ return self.__callTraceEnabled - @pyqtSlot(int, str, bool, str) - def __clientExit(self, status, message, quiet, debuggerId): + @pyqtSlot(str, int, str, bool, str) + def __clientExit(self, program, status, message, quiet, debuggerId): """ Private slot to handle a debug client terminating. + @param program name of the exited program + @type str @param status exit code of the debugged program @type int @param message exit message of the debugged program
--- a/eric6/Debugger/DebugServer.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/Debugger/DebugServer.py Sun Feb 16 16:14:25 2020 +0100 @@ -67,9 +67,9 @@ @signal clientSignal(message, filename, linenumber, function name, function arguments, debuggerId) emitted after a signal has been generated on the client side - @signal clientExit(int, str, bool, str) emitted after the client has exited - giving the exit status, an exit message, an indication to be quiet and - the ID of the exited client + @signal clientExit(str, int, str, bool, str) emitted after the client has + exited giving the program name, the exit status, an exit message, an + indication to be quiet and the ID of the exited client @signal lastClientExited() emitted to indicate that the last connected debug client has terminated @signal clientClearBreak(filename, lineno, debuggerId) emitted after the @@ -139,7 +139,7 @@ clientException = pyqtSignal(str, str, list, str) clientSyntaxError = pyqtSignal(str, str, int, int, str) clientSignal = pyqtSignal(str, str, int, str, str, str) - clientExit = pyqtSignal(int, str, bool, str) + clientExit = pyqtSignal(str, int, str, bool, str) lastClientExited = pyqtSignal() clientBreakConditionError = pyqtSignal(str, int, str) clientWatchConditionError = pyqtSignal(str, str) @@ -1788,10 +1788,12 @@ self.clientSignal.emit(message, filename, lineNo, funcName, funcArgs, debuggerId) - def signalClientExit(self, status, message, debuggerId): + def signalClientExit(self, program, status, message, debuggerId): """ Public method to process the client exit status. + @param program name of the exited program + @type str @param status exit code @type int @param message message sent with the exit @@ -1799,7 +1801,7 @@ @param debuggerId ID of the debugger backend @type str """ - self.clientExit.emit(int(status), message, False, debuggerId) + self.clientExit.emit(program, int(status), message, False, debuggerId) def signalLastClientExited(self): """ @@ -2068,7 +2070,7 @@ """ self.utFinished.emit() - self.clientExit.emit(int(status), "", True, "") + self.clientExit.emit("", int(status), "", True, "") self.debugging = False self.running = False
--- a/eric6/Debugger/DebugUI.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/Debugger/DebugUI.py Sun Feb 16 16:14:25 2020 +0100 @@ -1034,11 +1034,13 @@ self.debugActGrp.setEnabled(True) - @pyqtSlot(int, str, bool) - def __clientExit(self, status, message, quiet): + @pyqtSlot(str, int, str, bool) + def __clientExit(self, program, status, message, quiet): """ Private method to handle the debugged program terminating. + @param program name of the exited program + @type str @param status exit code of the debugged program @type int @param message exit message of the debugged program @@ -1047,6 +1049,8 @@ @type bool """ if not quiet: + if not program: + program = self.ui.currentProg if ( not Preferences.getDebugger("SuppressClientExit") or status != 0 @@ -1056,18 +1060,19 @@ Utilities.html_uencode(message)) else: info = "" - if self.ui.currentProg is None: + if program is None: E5MessageBox.information( - self.ui, Program, - self.tr('<p>The program has terminated with an exit' - ' status of {0}.</p>{1}').format(status, info)) + self.ui, Program, self.tr( + '<p>The program has terminated with an exit' + ' 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>{2}') - .format(Utilities.normabspath(self.ui.currentProg), - status, info)) + self.ui, Program, self.tr( + '<p><b>{0}</b> has terminated with an exit' + ' status of {1}.</p>{2}').format( + Utilities.normabspath(program), status, info) + ) else: if message: info = self.tr("Message: {0}").format( @@ -1075,7 +1080,7 @@ else: info = "" if self.ui.notificationsEnabled(): - if self.ui.currentProg is None: + if program is None: msg = self.tr( 'The program has terminated with an exit status of' ' {0}.\n{1}').format(status, info) @@ -1083,22 +1088,22 @@ msg = self.tr( '"{0}" has terminated with an exit status of' ' {1}.\n{2}').format( - os.path.basename(self.ui.currentProg), status, - info) + os.path.basename(program), status, info) self.ui.showNotification( UI.PixmapCache.getPixmap("debug48.png"), self.tr("Program terminated"), msg) else: - if self.ui.currentProg is None: + if program is None: self.appendStdout.emit(self.tr( 'The program has terminated with an exit status' - ' of {0}.\n{1}\n').format(status, info)) + ' of {0}.\n{1}\n').format(status, info) + ) else: self.appendStdout.emit(self.tr( '"{0}" has terminated with an exit status of' ' {1}.\n{2}\n').format( - Utilities.normabspath(self.ui.currentProg), status, - info)) + Utilities.normabspath(program), status, info) + ) def __lastClientExited(self): """
--- a/eric6/Debugger/DebugViewer.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/Debugger/DebugViewer.py Sun Feb 16 16:14:25 2020 +0100 @@ -439,11 +439,13 @@ if debuggerId != self.getSelectedDebuggerId(): self.__debuggersCombo.setCurrentText(debuggerId) - @pyqtSlot(int, str, bool, str) - def __clientExit(self, status, message, quiet, debuggerId): + @pyqtSlot(str, int, str, bool, str) + def __clientExit(self, program, status, message, quiet, debuggerId): """ Private method to handle the debugged program terminating. + @param program name of the exited program + @type str @param status exit code of the debugged program @type int @param message exit message of the debugged program
--- a/eric6/Debugger/DebuggerInterfacePython.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/Debugger/DebuggerInterfacePython.py Sun Feb 16 16:14:25 2020 +0100 @@ -1488,7 +1488,8 @@ elif method == "ResponseExit": self.__scriptName = "" self.debugServer.signalClientExit( - params["status"], params["message"], params["debuggerId"]) + params["program"], params["status"], params["message"], + params["debuggerId"]) elif method == "PassiveStartup": self.debugServer.passiveStartUp(
--- a/eric6/Utilities/BackgroundClient.py Sun Feb 16 12:42:12 2020 +0100 +++ b/eric6/Utilities/BackgroundClient.py Sun Feb 16 16:14:25 2020 +0100 @@ -11,7 +11,7 @@ from __future__ import unicode_literals try: - bytes = unicode + bytes = unicode # __IGNORE_EXCEPTION__ import StringIO as io # __IGNORE_EXCEPTION__ except NameError: import io # __IGNORE_WARNING__