Cleaned up the modified code for the modernized debugger interface (Python3 variant). jsonrpc

Fri, 02 Sep 2016 19:50:20 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 02 Sep 2016 19:50:20 +0200
branch
jsonrpc
changeset 5129
e4ab234cf071
parent 5128
b6cbdba69967
child 5130
27fe451262bf

Cleaned up the modified code for the modernized debugger interface (Python3 variant).

DebugClients/Python3/AsyncFile.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DCTestResult.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugClientBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugUtilities.py file | annotate | diff | comparison | revisions
Debugger/DebuggerInterfacePython3.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python3/AsyncFile.py	Fri Sep 02 19:14:41 2016 +0200
+++ b/DebugClients/Python3/AsyncFile.py	Fri Sep 02 19:50:20 2016 +0200
@@ -10,6 +10,8 @@
 
 import socket
 
+from DebugUtilities import prepareJsonCommand
+
 
 def AsyncPendingWrite(file):
     """
@@ -297,16 +299,9 @@
         """
         self.__checkMode('w')
         
-        import json
-        commandDict = {
-            "jsonrpc": "2.0",
-            "method": "ClientOutput",
-            "params": {
-                "text": s,
-            }
-        }
-        cmd = json.dumps(commandDict) + '\n'
-        
+        cmd = prepareJsonCommand("ClientOutput", {
+            "text": s,
+        })
         self.write_p(cmd)
     
     def write_p(self, s):
--- a/DebugClients/Python3/DCTestResult.py	Fri Sep 02 19:14:41 2016 +0200
+++ b/DebugClients/Python3/DCTestResult.py	Fri Sep 02 19:50:20 2016 +0200
@@ -11,11 +11,6 @@
 from unittest import TestResult
 
 
-##from DebugProtocol import ResponseUTTestFailed, ResponseUTTestErrored, \
-##    ResponseUTStartTest, ResponseUTStopTest, ResponseUTTestSkipped, \
-##    ResponseUTTestFailedExpected, ResponseUTTestSucceededUnexpected
-
-
 class DCTestResult(TestResult):
     """
     A TestResult derivative to work with eric6's debug client.
@@ -41,9 +36,6 @@
         """
         TestResult.addFailure(self, test, err)
         tracebackLines = self._exc_info_to_string(err, test)
-##        self.parent.write('{0}{1}\n'.format(
-##            ResponseUTTestFailed,
-##            str((str(test), tracebackLines, test.id()))))
         self.__dbgClient.sendJsonCommand("ResponseUTTestFailed", {
             "testname": str(test),
             "traceback": tracebackLines,
@@ -59,9 +51,6 @@
         """
         TestResult.addError(self, test, err)
         tracebackLines = self._exc_info_to_string(err, test)
-##        self.parent.write('{0}{1}\n'.format(
-##            ResponseUTTestErrored,
-##            str((str(test), tracebackLines, test.id()))))
         self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", {
             "testname": str(test),
             "traceback": tracebackLines,
@@ -76,9 +65,6 @@
         @param reason reason for skipping the test (string)
         """
         TestResult.addSkip(self, test, reason)
-##        self.parent.write('{0}{1}\n'.format(
-##            ResponseUTTestSkipped,
-##            str((str(test), reason, test.id()))))
         self.__dbgClient.sendJsonCommand("ResponseUTTestSkipped", {
             "testname": str(test),
             "reason": reason,
@@ -94,9 +80,6 @@
         """
         TestResult.addExpectedFailure(self, test, err)
         tracebackLines = self._exc_info_to_string(err, test)
-##        self.parent.write('{0}{1}\n'.format(
-##            ResponseUTTestFailedExpected,
-##            str((str(test), tracebackLines, test.id()))))
         self.__dbgClient.sendJsonCommand("ResponseUTTestFailedExpected", {
             "testname": str(test),
             "traceback": tracebackLines,
@@ -110,9 +93,6 @@
         @param test reference to the test object
         """
         TestResult.addUnexpectedSuccess(self, test)
-##        self.parent.write('{0}{1}\n'.format(
-##            ResponseUTTestSucceededUnexpected,
-##            str((str(test), test.id()))))
         self.__dbgClient.sendJsonCommand("ResponseUTTestSucceededUnexpected", {
             "testname": str(test),
             "id": test.id(),
@@ -125,9 +105,6 @@
         @param test Reference to the test object
         """
         TestResult.startTest(self, test)
-##        self.parent.write('{0}{1}\n'.format(
-##            ResponseUTStartTest,
-##            str((str(test), test.shortDescription()))))
         self.__dbgClient.sendJsonCommand("ResponseUTStartTest", {
             "testname": str(test),
             "description": test.shortDescription(),
@@ -140,7 +117,6 @@
         @param test Reference to the test object
         """
         TestResult.stopTest(self, test)
-##        self.parent.write('{0}\n'.format(ResponseUTStopTest))
         self.__dbgClient.sendJsonCommand("ResponseUTStopTest", {})
         
         # ensure that pending input is processed
--- a/DebugClients/Python3/DebugClientBase.py	Fri Sep 02 19:14:41 2016 +0200
+++ b/DebugClients/Python3/DebugClientBase.py	Fri Sep 02 19:50:20 2016 +0200
@@ -20,13 +20,12 @@
 import signal
 
 
-##import DebugProtocol
 import DebugClientCapabilities
 from DebugBase import setRecursionLimit, printerr   # __IGNORE_WARNING__
 from AsyncFile import AsyncFile, AsyncPendingWrite
 from DebugConfig import ConfigVarTypeStrings
 from FlexCompleter import Completer
-from DebugUtilities import getargvalues, formatargvalues
+from DebugUtilities import getargvalues, formatargvalues, prepareJsonCommand
 
 
 DebugClientInstance = None
@@ -189,10 +188,8 @@
         self.globalsFilterObjects = []
         self.localsFilterObjects = []
 
-##        self.pendingResponse = DebugProtocol.ResponseOK
         self._fncache = {}
         self.dircache = []
-##        self.inRawMode = False
         self.mainProcStr = None     # used for the passive mode
         self.passive = False        # used to indicate the passive mode
         self.running = None
@@ -303,8 +300,6 @@
                 d["broken"] = False
             threadList.append(d)
         
-##        self.write("{0}{1!r}\n".format(DebugProtocol.ResponseThreadList,
-##                                       (currentId, threadList)))
         self.sendJsonCommand("ResponseThreadList", {
             "currentID": currentId,
             "threadList": threadList,
@@ -318,25 +313,13 @@
         @param echo Flag indicating echoing of the input (boolean)
         @return the entered string
         """
-##        self.write("{0}{1!r}\n".format(
-##            DebugProtocol.ResponseRaw, (prompt, echo)))
         self.sendJsonCommand("RequestRaw", {
             "prompt": prompt,
             "echo": echo,
         })
-##        self.inRawMode = True
         self.eventLoop(True)
         return self.rawLine
 
-##    def __exceptionRaised(self):
-##        """
-##        Private method called in the case of an exception.
-##        
-##        It ensures that the debug server is informed of the raised exception.
-##        """
-####        self.pendingResponse = DebugProtocol.ResponseException
-##        self.sendJsonCommand("ResponseException", {})
-##    
     def sessionClose(self, exit=True):
         """
         Public method to close the session with the debugger and optionally
@@ -349,8 +332,6 @@
         except Exception:
             pass
 
-##        # clean up asyncio.
-##        self.disconnect()
         self.debugging = False
         
         # make sure we close down our end of the socket
@@ -409,629 +390,14 @@
 
 ##        printerr(line)          ##debug
         
-        if line.startswith("{") and "jsonrpc" in line:
-            return self.handleJsonCommand(line)
-##
-##        eoc = line.find('<')
-##
-##        if eoc >= 0 and line[0] == '>':
-##            # Get the command part and any argument.
-##            cmd = line[:eoc + 1]
-##            arg = line[eoc + 1:]
-##            
-##            if cmd == DebugProtocol.RequestVariables:
-##                frmnr, scope, filter = eval(arg.replace("u'", "'"))
-##                self.__dumpVariables(int(frmnr), int(scope), filter)
-##                return
-##            
-##            if cmd == DebugProtocol.RequestVariable:
-##                var, frmnr, scope, filter = eval(arg.replace("u'", "'"))
-##                self.__dumpVariable(var, int(frmnr), int(scope), filter)
-##                return
-##            
-##            if cmd == DebugProtocol.RequestThreadList:
-##                self.__dumpThreadList()
-##                return
-##            
-##            if cmd == DebugProtocol.RequestThreadSet:
-##                tid = eval(arg)
-##                if tid in self.threads:
-##                    self.setCurrentThread(tid)
-##                    self.write(DebugProtocol.ResponseThreadSet + '\n')
-##                    stack = self.currentThread.getStack()
-##                    self.write('{0}{1!r}\n'.format(
-##                        DebugProtocol.ResponseStack, stack))
-##                return
-##            
-##            if cmd == DebugProtocol.RequestStep:
-##                self.currentThread.step(True)
-##                self.eventExit = True
-##                return
-##
-##            if cmd == DebugProtocol.RequestStepOver:
-##                self.currentThread.step(False)
-##                self.eventExit = True
-##                return
-##            
-##            if cmd == DebugProtocol.RequestStepOut:
-##                self.currentThread.stepOut()
-##                self.eventExit = True
-##                return
-##            
-##            if cmd == DebugProtocol.RequestStepQuit:
-##                if self.passive:
-##                    self.progTerminated(42)
-##                else:
-##                    self.set_quit()
-##                    self.eventExit = True
-##                return
-##
-##            if cmd == DebugProtocol.RequestContinue:
-##                special = int(arg)
-##                self.currentThread.go(special)
-##                self.eventExit = True
-##                return
-##
-##            if cmd == DebugProtocol.RequestOK:
-##                self.write(self.pendingResponse + '\n')
-##                self.pendingResponse = DebugProtocol.ResponseOK
-##                return
-##
-##            if cmd == DebugProtocol.RequestCallTrace:
-##                if arg.strip().lower() == "on":
-##                    callTraceEnabled = True
-##                else:
-##                    callTraceEnabled = False
-##                if self.debugging:
-##                    self.callTraceEnabled = callTraceEnabled
-##                else:
-##                    self.__newCallTraceEnabled = callTraceEnabled
-##                    # remember for later
-##                return
-##            
-##            if cmd == DebugProtocol.RequestEnv:
-##                env = eval(arg.replace("u'", "'"))
-##                for key, value in env.items():
-##                    if key.endswith("+"):
-##                        if key[:-1] in os.environ:
-##                            os.environ[key[:-1]] += value
-##                        else:
-##                            os.environ[key[:-1]] = value
-##                    else:
-##                        os.environ[key] = value
-##                return
-##
-##            if cmd == DebugProtocol.RequestLoad:
-##                self._fncache = {}
-##                self.dircache = []
-##                sys.argv = []
-##                wd, fn, args, tracePython = arg.split('|')
-##                self.__setCoding(fn)
-##                sys.argv.append(fn)
-##                sys.argv.extend(eval(args))
-##                sys.path = self.__getSysPath(os.path.dirname(sys.argv[0]))
-##                if wd == '':
-##                    os.chdir(sys.path[1])
-##                else:
-##                    os.chdir(wd)
-##                tracePython = int(tracePython)
-##                self.running = sys.argv[0]
-##                self.mainFrame = None
-##                self.inRawMode = False
-##                self.debugging = True
-##                
-##                self.threads.clear()
-##                self.attachThread(mainThread=True)
-##                
-##                # set the system exception handling function to ensure, that
-##                # we report on all unhandled exceptions
-##                sys.excepthook = self.__unhandled_exception
-##                self.__interceptSignals()
-##                
-##                # clear all old breakpoints, they'll get set after we have
-##                # started
-##                self.mainThread.clear_all_breaks()
-##                
-##                self.mainThread.tracePython = tracePython
-##                
-##                # This will eventually enter a local event loop.
-##                self.debugMod.__dict__['__file__'] = self.running
-##                sys.modules['__main__'] = self.debugMod
-##                code = self.__compileFileSource(self.running)
-##                if code:
-##                    self.callTraceEnabled = self.__newCallTraceEnabled
-##                    res = self.mainThread.run(code, self.debugMod.__dict__)
-##                    self.progTerminated(res)
-##                return
-##
-##            if cmd == DebugProtocol.RequestRun:
-##                sys.argv = []
-##                wd, fn, args = arg.split('|')
-##                self.__setCoding(fn)
-##                sys.argv.append(fn)
-##                sys.argv.extend(eval(args))
-##                sys.path = self.__getSysPath(os.path.dirname(sys.argv[0]))
-##                if wd == '':
-##                    os.chdir(sys.path[1])
-##                else:
-##                    os.chdir(wd)
-##
-##                self.running = sys.argv[0]
-##                self.mainFrame = None
-##                self.botframe = None
-##                self.inRawMode = False
-##                
-##                self.threads.clear()
-##                self.attachThread(mainThread=True)
-##                
-##                # set the system exception handling function to ensure, that
-##                # we report on all unhandled exceptions
-##                sys.excepthook = self.__unhandled_exception
-##                self.__interceptSignals()
-##                
-##                self.mainThread.tracePython = False
-##                
-##                self.debugMod.__dict__['__file__'] = sys.argv[0]
-##                sys.modules['__main__'] = self.debugMod
-##                res = 0
-##                code = self.__compileFileSource(self.running)
-##                if code:
-##                    try:
-##                        exec(code, self.debugMod.__dict__)
-##                    except SystemExit as exc:
-##                        res = exc.code
-##                        atexit._run_exitfuncs()
-##                    self.writestream.flush()
-##                    self.progTerminated(res)
-##                return
-##
-##            if cmd == DebugProtocol.RequestProfile:
-##                sys.setprofile(None)
-##                import PyProfile
-##                sys.argv = []
-##                wd, fn, args, erase = arg.split('|')
-##                self.__setCoding(fn)
-##                sys.argv.append(fn)
-##                sys.argv.extend(eval(args))
-##                sys.path = self.__getSysPath(os.path.dirname(sys.argv[0]))
-##                if wd == '':
-##                    os.chdir(sys.path[1])
-##                else:
-##                    os.chdir(wd)
-##
-##                # set the system exception handling function to ensure, that
-##                # we report on all unhandled exceptions
-##                sys.excepthook = self.__unhandled_exception
-##                self.__interceptSignals()
-##                
-##                # generate a profile object
-##                self.prof = PyProfile.PyProfile(sys.argv[0])
-##                
-##                if int(erase):
-##                    self.prof.erase()
-##                self.debugMod.__dict__['__file__'] = sys.argv[0]
-##                sys.modules['__main__'] = self.debugMod
-##                fp = open(sys.argv[0], encoding=self.__coding)
-##                try:
-##                    script = fp.read()
-##                finally:
-##                    fp.close()
-##                if script:
-##                    if not script.endswith('\n'):
-##                        script += '\n'
-##                    self.running = sys.argv[0]
-##                    res = 0
-##                    try:
-##                        self.prof.run(script)
-##                    except SystemExit as exc:
-##                        res = exc.code
-##                        atexit._run_exitfuncs()
-##                    self.prof.save()
-##                    self.writestream.flush()
-##                    self.progTerminated(res)
-##                return
-##
-##            if cmd == DebugProtocol.RequestCoverage:
-##                from coverage import coverage
-##                sys.argv = []
-##                wd, fn, args, erase = arg.split('@@')
-##                self.__setCoding(fn)
-##                sys.argv.append(fn)
-##                sys.argv.extend(eval(args))
-##                sys.path = self.__getSysPath(os.path.dirname(sys.argv[0]))
-##                if wd == '':
-##                    os.chdir(sys.path[1])
-##                else:
-##                    os.chdir(wd)
-##                
-##                # set the system exception handling function to ensure, that
-##                # we report on all unhandled exceptions
-##                sys.excepthook = self.__unhandled_exception
-##                self.__interceptSignals()
-##                
-##                # generate a coverage object
-##                self.cover = coverage(
-##                    auto_data=True,
-##                    data_file="{0}.coverage".format(
-##                        os.path.splitext(sys.argv[0])[0]))
-##                
-##                if int(erase):
-##                    self.cover.erase()
-##                sys.modules['__main__'] = self.debugMod
-##                self.debugMod.__dict__['__file__'] = sys.argv[0]
-##                fp = open(sys.argv[0], encoding=self.__coding)
-##                try:
-##                    script = fp.read()
-##                finally:
-##                    fp.close()
-##                if script:
-##                    if not script.endswith('\n'):
-##                        script += '\n'
-##                    code = compile(script, sys.argv[0], 'exec')
-##                    self.running = sys.argv[0]
-##                    res = 0
-##                    self.cover.start()
-##                    try:
-##                        exec(code, self.debugMod.__dict__)
-##                    except SystemExit as exc:
-##                        res = exc.code
-##                        atexit._run_exitfuncs()
-##                    self.cover.stop()
-##                    self.cover.save()
-##                    self.writestream.flush()
-##                    self.progTerminated(res)
-##                return
-##
-##            if cmd == DebugProtocol.RequestShutdown:
-##                self.sessionClose()
-##                return
-##            
-##            if cmd == DebugProtocol.RequestBreak:
-##                fn, line, temporary, set, cond = arg.split('@@')
-##                line = int(line)
-##                set = int(set)
-##                temporary = int(temporary)
-##
-##                if set:
-##                    if cond == 'None' or cond == '':
-##                        cond = None
-##                    else:
-##                        try:
-##                            compile(cond, '<string>', 'eval')
-##                        except SyntaxError:
-##                            self.write('{0}{1},{2:d}\n'.format(
-##                                       DebugProtocol.ResponseBPConditionError,
-##                                       fn, line))
-##                            return
-##                    self.mainThread.set_break(fn, line, temporary, cond)
-##                else:
-##                    self.mainThread.clear_break(fn, line)
-##
-##                return
-##            
-##            if cmd == DebugProtocol.RequestBreakEnable:
-##                fn, line, enable = arg.split(',')
-##                line = int(line)
-##                enable = int(enable)
-##                
-##                bp = self.mainThread.get_break(fn, line)
-##                if bp is not None:
-##                    if enable:
-##                        bp.enable()
-##                    else:
-##                        bp.disable()
-##                
-##                return
-##            
-##            if cmd == DebugProtocol.RequestBreakIgnore:
-##                fn, line, count = arg.split(',')
-##                line = int(line)
-##                count = int(count)
-##                
-##                bp = self.mainThread.get_break(fn, line)
-##                if bp is not None:
-##                    bp.ignore = count
-##                
-##                return
-##            
-##            if cmd == DebugProtocol.RequestWatch:
-##                cond, temporary, set = arg.split('@@')
-##                set = int(set)
-##                temporary = int(temporary)
-##
-##                if set:
-##                    if not cond.endswith('??created??') and \
-##                       not cond.endswith('??changed??'):
-##                        try:
-##                            compile(cond, '<string>', 'eval')
-##                        except SyntaxError:
-##                            self.write('{0}{1}\n'.format(
-##                                DebugProtocol.ResponseWPConditionError, cond))
-##                            return
-##                    self.mainThread.set_watch(cond, temporary)
-##                else:
-##                    self.mainThread.clear_watch(cond)
-##
-##                return
-##            
-##            if cmd == DebugProtocol.RequestWatchEnable:
-##                cond, enable = arg.split(',')
-##                enable = int(enable)
-##                
-##                bp = self.mainThread.get_watch(cond)
-##                if bp is not None:
-##                    if enable:
-##                        bp.enable()
-##                    else:
-##                        bp.disable()
-##                
-##                return
-##            
-##            if cmd == DebugProtocol.RequestWatchIgnore:
-##                cond, count = arg.split(',')
-##                count = int(count)
-##                
-##                bp = self.mainThread.get_watch(cond)
-##                if bp is not None:
-##                    bp.ignore = count
-##                
-##                return
-##            
-##            if cmd == DebugProtocol.RequestEval:
-##                try:
-##                    value = eval(
-##                        arg,
-##                        self.currentThread.getCurrentFrame().f_globals,
-##                        self.currentThread.getFrameLocals(self.framenr))
-##                    self.currentThread.storeFrameLocals(self.framenr)
-##                except Exception:
-##                    # Report the exception and the traceback
-##                    try:
-##                        type, value, tb = sys.exc_info()
-##                        sys.last_type = type
-##                        sys.last_value = value
-##                        sys.last_traceback = tb
-##                        tblist = traceback.extract_tb(tb)
-##                        del tblist[:1]
-##                        list = traceback.format_list(tblist)
-##                        if list:
-##                            list.insert(0, "Traceback (innermost last):\n")
-##                            list[len(list):] = \
-##                                traceback.format_exception_only(type, value)
-##                    finally:
-##                        tblist = tb = None
-##
-##                    for l in list:
-##                        self.write(l)
-##
-##                    self.write(DebugProtocol.ResponseException + '\n')
-##                
-##                else:
-##                    self.write(str(value) + '\n')
-##                    self.write(DebugProtocol.ResponseOK + '\n')
-##                
-##                return
-##            
-##            if cmd == DebugProtocol.RequestExec:
-##                _globals = self.currentThread.getCurrentFrame().f_globals
-##                _locals = self.currentThread.getFrameLocals(self.framenr)
-##                try:
-##                    code = compile(arg + '\n', '<stdin>', 'single')
-##                    exec(code, _globals, _locals)
-##                    self.currentThread.storeFrameLocals(self.framenr)
-##                except Exception:
-##                    # Report the exception and the traceback
-##                    try:
-##                        type, value, tb = sys.exc_info()
-##                        sys.last_type = type
-##                        sys.last_value = value
-##                        sys.last_traceback = tb
-##                        tblist = traceback.extract_tb(tb)
-##                        del tblist[:1]
-##                        list = traceback.format_list(tblist)
-##                        if list:
-##                            list.insert(0, "Traceback (innermost last):\n")
-##                            list[len(list):] = \
-##                                traceback.format_exception_only(type, value)
-##                    finally:
-##                        tblist = tb = None
-##
-##                    for l in list:
-##                        self.write(l)
-##
-##                    self.write(DebugProtocol.ResponseException + '\n')
-##                
-##                return
-##            
-##            if cmd == DebugProtocol.RequestBanner:
-##                self.write('{0}{1}\n'.format(DebugProtocol.ResponseBanner,
-##                           str(("Python {0}".format(sys.version),
-##                                socket.gethostname(), self.variant))))
-##                return
-##            
-##            if cmd == DebugProtocol.RequestCapabilities:
-##                self.write('{0}{1:d}, "Python3"\n'.format(
-##                    DebugProtocol.ResponseCapabilities,
-##                    self.__clientCapabilities()))
-##                return
-##            
-##            if cmd == DebugProtocol.RequestCompletion:
-##                self.__completionList(arg.replace("u'", "'"))
-##                return
-##            
-##            if cmd == DebugProtocol.RequestSetFilter:
-##                scope, filterString = eval(arg.replace("u'", "'"))
-##                self.__generateFilterObjects(int(scope), filterString)
-##                return
-##            
-##            if cmd == DebugProtocol.RequestUTPrepare:
-##                fn, tn, tfn, failed, cov, covname, erase = arg.split('|')
-##                sys.path.insert(0, os.path.dirname(os.path.abspath(fn)))
-##                os.chdir(sys.path[0])
-##                failed = eval(failed)
-##
-##                # set the system exception handling function to ensure, that
-##                # we report on all unhandled exceptions
-##                sys.excepthook = self.__unhandled_exception
-##                self.__interceptSignals()
-##                
-##                try:
-##                    import unittest
-##                    utModule = imp.load_source(tn, fn)
-##                    try:
-##                        if failed:
-##                            self.test = unittest.defaultTestLoader\
-##                                .loadTestsFromNames(failed, utModule)
-##                        else:
-##                            self.test = unittest.defaultTestLoader\
-##                                .loadTestsFromName(tfn, utModule)
-##                    except AttributeError:
-##                        self.test = unittest.defaultTestLoader\
-##                            .loadTestsFromModule(utModule)
-##                except Exception:
-##                    exc_type, exc_value, exc_tb = sys.exc_info()
-##                    self.write('{0}{1}\n'.format(
-##                        DebugProtocol.ResponseUTPrepared,
-##                        str((0, str(exc_type), str(exc_value)))))
-##                    self.__exceptionRaised()
-##                    return
-##                
-##                # generate a coverage object
-##                if int(cov):
-##                    from coverage import coverage
-##                    self.cover = coverage(
-##                        auto_data=True,
-##                        data_file="{0}.coverage".format(
-##                            os.path.splitext(covname)[0]))
-##                    if int(erase):
-##                        self.cover.erase()
-##                else:
-##                    self.cover = None
-##                
-##                self.write('{0}{1}\n'.format(
-##                    DebugProtocol.ResponseUTPrepared,
-##                    str((self.test.countTestCases(), "", ""))))
-##                return
-##            
-##            if cmd == DebugProtocol.RequestUTRun:
-##                from DCTestResult import DCTestResult
-##                self.testResult = DCTestResult(self)
-##                if self.cover:
-##                    self.cover.start()
-##                self.test.run(self.testResult)
-##                if self.cover:
-##                    self.cover.stop()
-##                    self.cover.save()
-##                self.write('{0}\n'.format(DebugProtocol.ResponseUTFinished))
-##                return
-##            
-##            if cmd == DebugProtocol.RequestUTStop:
-##                self.testResult.stop()
-##                return
-##        
-##            if cmd == DebugProtocol.ResponseForkTo:
-##                # this results from a separate event loop
-##                self.fork_child = (arg == 'child')
-##                self.eventExit = True
-##                return
-##            
-##            if cmd == DebugProtocol.RequestForkMode:
-##                self.fork_auto, self.fork_child = eval(arg)
-##                return
-##        
-##        # If we are handling raw mode input then reset the mode and break out
-##        # of the current event loop.
-##        if self.inRawMode:
-##            self.inRawMode = False
-##            self.rawLine = line
-##            self.eventExit = True
-##            return
-##
-##        if self.buffer:
-##            self.buffer = self.buffer + '\n' + line
-##        else:
-##            self.buffer = line
-##
-##        try:
-##            code = self.compile_command(self.buffer, self.readstream.name)
-##        except (OverflowError, SyntaxError, ValueError):
-##            # Report the exception
-##            sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
-##            for l in traceback.format_exception_only(
-##                    sys.last_type, sys.last_value):
-##                self.write(l)
-##            self.buffer = ''
-##        else:
-##            if code is None:
-##                self.pendingResponse = DebugProtocol.ResponseContinue
-##            else:
-##                self.buffer = ''
-##
-##                try:
-##                    if self.running is None:
-##                        exec(code, self.debugMod.__dict__)
-##                    else:
-##                        if self.currentThread is None:
-##                            # program has terminated
-##                            self.running = None
-##                            _globals = self.debugMod.__dict__
-##                            _locals = _globals
-##                        else:
-##                            cf = self.currentThread.getCurrentFrame()
-##                            # program has terminated
-##                            if cf is None:
-##                                self.running = None
-##                                _globals = self.debugMod.__dict__
-##                                _locals = _globals
-##                            else:
-##                                frmnr = self.framenr
-##                                while cf is not None and frmnr > 0:
-##                                    cf = cf.f_back
-##                                    frmnr -= 1
-##                                _globals = cf.f_globals
-##                                _locals = \
-##                                    self.currentThread.getFrameLocals(
-##                                        self.framenr)
-##                        # reset sys.stdout to our redirector (unconditionally)
-##                        if "sys" in _globals:
-##                            __stdout = _globals["sys"].stdout
-##                            _globals["sys"].stdout = self.writestream
-##                            exec(code, _globals, _locals)
-##                            _globals["sys"].stdout = __stdout
-##                        elif "sys" in _locals:
-##                            __stdout = _locals["sys"].stdout
-##                            _locals["sys"].stdout = self.writestream
-##                            exec(code, _globals, _locals)
-##                            _locals["sys"].stdout = __stdout
-##                        else:
-##                            exec(code, _globals, _locals)
-##                        
-##                        self.currentThread.storeFrameLocals(self.framenr)
-##                except SystemExit as exc:
-##                    self.progTerminated(exc.code)
-##                except Exception:
-##                    # Report the exception and the traceback
-##                    try:
-##                        exc_type, exc_value, exc_tb = sys.exc_info()
-##                        sys.last_type = exc_type
-##                        sys.last_value = exc_value
-##                        sys.last_traceback = exc_tb
-##                        tblist = traceback.extract_tb(exc_tb)
-##                        del tblist[:1]
-##                        list = traceback.format_list(tblist)
-##                        if list:
-##                            list.insert(0, "Traceback (innermost last):\n")
-##                            list[len(list):] = traceback.format_exception_only(
-##                                exc_type, exc_value)
-##                    finally:
-##                        tblist = exc_tb = None
-##
-##                    for l in list:
-##                        self.write(l)
+        self.handleJsonCommand(line)
     
     def handleJsonCommand(self, jsonStr):
         """
         Public method to handle a command serialized as a JSON string.
+        
+        @param jsonStr string containing the command received from the IDE
+        @type str
         """
         import json
         
@@ -1113,7 +479,6 @@
             
             self.running = sys.argv[0]
             self.mainFrame = None
-##            self.inRawMode = False
             self.debugging = True
             
             self.fork_auto = params["autofork"]
@@ -1156,7 +521,6 @@
             self.running = sys.argv[0]
             self.mainFrame = None
             self.botframe = None
-##            self.inRawMode = False
             
             self.fork_auto = params["autofork"]
             self.fork_child = params["forkChild"]
@@ -1289,9 +653,6 @@
                 # Report the exception
                 sys.last_type, sys.last_value, sys.last_traceback = \
                     sys.exc_info()
-##                for l in traceback.format_exception_only(
-##                        sys.last_type, sys.last_value):
-##                    self.write(l)
                 self.sendJsonCommand("ClientOutput", {
                     "text": "".join(traceback.format_exception_only(
                         sys.last_type, sys.last_value))
@@ -1367,8 +728,6 @@
                         finally:
                             tblist = exc_tb = None
 
-##                        for l in list:
-##                            self.write(l)
                         self.sendJsonCommand("ClientOutput", {
                             "text": "".join(tlist)
                         })
@@ -1500,7 +859,6 @@
                     "exception": exc_type.__name__,
                     "message": str(exc_value),
                 })
-##                self.__exceptionRaised()
                 return
             
             # generate a coverage object
@@ -1540,23 +898,17 @@
             self.fork_child = (params["target"] == 'child')
             self.eventExit = True
     
-    def sendJsonCommand(self, command, params):
+    def sendJsonCommand(self, method, params):
         """
-        Public method to send a single command to the client.
+        Public method to send a single command or response to the IDE.
         
-        @param command command name to be sent
+        @param method command or response command name to be sent
         @type str
-        @param params dictionary of named parameters for the command
+        @param params dictionary of named parameters for the command or
+            response
         @type dict
         """
-        import json
-        
-        commandDict = {
-            "jsonrpc": "2.0",
-            "method": command,
-            "params": params,
-        }
-        cmd = json.dumps(commandDict) + '\n'
+        cmd = prepareJsonCommand(method, params)
         
         self.writestream.write_p(cmd)
         self.writestream.flush()
@@ -1603,7 +955,7 @@
         
         @param event trace event (call or return)
         @type str
-        @param fromstr pre-formatted origin info
+        @param fromStr pre-formatted origin info
         @type str
         @param toStr pre-formatted target info
         @type str
@@ -1623,7 +975,7 @@
         @param exceptionMessage message of the exception
         @type str
         @param stack stack trace information
-        @param list
+        @type list
         """
         self.sendJsonCommand("ResponseException", {
             "type": exceptionType,
@@ -1682,20 +1034,11 @@
             return (
                 self.clientCapabilities & ~DebugClientCapabilities.HasProfiler)
     
-##    def write(self, s):
-##        """
-##        Public method to write data to the output stream.
-##        
-##        @param s data to be written (string)
-##        """
-##        self.writestream.write_p(s)
-##        self.writestream.flush()
-##
     def readReady(self, stream):
         """
         Public method called when there is data ready to be read.
         
-        @param fd file descriptor of the file that has data to be read (int)
+        @param stream file like object that has data to be written
         """
         try:
             got = stream.readline_p()
@@ -1720,7 +1063,7 @@
         """
         Public method called when we are ready to write data.
         
-        @param fd file descriptor of the file that has data to be written (int)
+        @param stream file like object that has data to be written
         """
         stream.write_p("")
         stream.flush()
@@ -1731,7 +1074,6 @@
         """
         global DebugClientInstance
 
-##        self.setDescriptors(self.readstream, self.writestream)
         DebugClientInstance = self
         self.__receiveBuffer = ""
 
@@ -1911,14 +1253,11 @@
         else:
             fargs = ""
         
-##        siglist = [message, [filename, linenr, ffunc, fargs]]
-##        
-##        self.write("{0}{1}".format(DebugProtocol.ResponseSignal, str(siglist)))
         self.sendJsonCommand("ResponseSignal", {
             "message": message,
-            "filename": filename, 
-            "linenumber": linenr, 
-            "function": ffunc, 
+            "filename": filename,
+            "linenumber": linenr,
+            "function": ffunc,
             "arguments": fargs,
         })
     
@@ -2015,7 +1354,6 @@
         if self.running:
             self.set_quit()
             self.running = None
-##            self.write('{0}{1:d}\n'.format(DebugProtocol.ResponseExit, status))
             self.sendJsonCommand("ResponseExit", {
                 "status": status,
                 "message": message,
@@ -2066,8 +1404,6 @@
             vlist = self.__formatVariablesList(keylist, dict, scope, filter)
             varlist.extend(vlist)
         
-##        self.write('{0}{1}\n'.format(
-##            DebugProtocol.ResponseVariables, str(varlist)))
         self.sendJsonCommand("ResponseVariables", {
             "scope": scope,
             "variables": varlist,
@@ -2355,8 +1691,6 @@
                 except Exception:
                     pass
         
-##        self.write('{0}{1}\n'.format(
-##            DebugProtocol.ResponseVariable, str(varlist)))
         self.sendJsonCommand("ResponseVariable", {
             "scope": scope,
             "variable": var,
@@ -2657,11 +1991,9 @@
             pass
         self.__getCompletionList(text, self.complete, completions)
         
-##        self.write("{0}{1}||{2}\n".format(DebugProtocol.ResponseCompletion,
-##                                          str(list(completions)), text))
         self.sendJsonCommand("ResponseCompletion", {
             "completions": list(completions),
-            "text": text, 
+            "text": text,
         })
 
     def __getCompletionList(self, text, completer, completions):
@@ -2727,7 +2059,6 @@
         self._fncache = {}
         self.dircache = []
         self.mainFrame = None
-##        self.inRawMode = False
         self.debugging = True
         
         self.attachThread(mainThread=True)
@@ -2780,13 +2111,10 @@
         self.running = sys.argv[0]
         self.__setCoding(self.running)
         self.mainFrame = None
-##        self.inRawMode = False
         self.debugging = True
         
         self.passive = True
         self.sendPassiveStartup(self.running, exceptions)
-##        self.write("{0}{1}|{2:d}\n".format(
-##            DebugProtocol.PassiveStartup, self.running, exceptions))
         self.__interact()
         
         self.attachThread(mainThread=True)
@@ -2943,7 +2271,6 @@
         @return process ID (integer)
         """
         if not self.fork_auto:
-##            self.write(DebugProtocol.RequestForkTo + '\n')
             self.sendJsonCommand("RequestForkTo", {})
             self.eventLoop(True)
         pid = DebugClientOrigFork()
--- a/DebugClients/Python3/DebugUtilities.py	Fri Sep 02 19:14:41 2016 +0200
+++ b/DebugClients/Python3/DebugUtilities.py	Fri Sep 02 19:50:20 2016 +0200
@@ -123,5 +123,27 @@
         argvalues += " -> " + formatvalue(locals['__return__'])
     return argvalues
 
+
+def prepareJsonCommand(method, params):
+    """
+    Function to prepare a single command or response for transmission to
+    the IDE.
+    
+    @param method command or response name to be sent
+    @type str
+    @param params dictionary of named parameters for the command or response
+    @type dict
+    @return prepared JSON command or response string
+    @rtype str
+    """
+    import json
+    
+    commandDict = {
+        "jsonrpc": "2.0",
+        "method": method,
+        "params": params,
+    }
+    return json.dumps(commandDict) + '\n'
+
 #
 # eflag: noqa = M702
--- a/Debugger/DebuggerInterfacePython3.py	Fri Sep 02 19:14:41 2016 +0200
+++ b/Debugger/DebuggerInterfacePython3.py	Fri Sep 02 19:50:20 2016 +0200
@@ -19,7 +19,6 @@
 from E5Gui.E5Application import e5App
 from E5Gui import E5MessageBox
 
-##from . import DebugProtocol
 from . import DebugClientCapabilities
 
 import Preferences
@@ -29,7 +28,6 @@
 
 
 ClientDefaultCapabilities = DebugClientCapabilities.HasAll
-##EOT = '>EOT<\n'
 
 
 class DebuggerInterfacePython3(QObject):
@@ -405,7 +403,6 @@
         self.qsock.readyRead.disconnect(self.__parseClientLine)
         
         # close down socket, and shut down client as well.
-##        self.__sendCommand('{0}\n'.format(DebugProtocol.RequestShutdown))
         self.__sendJsonCommand("RequestShutdown", {})
         self.qsock.flush()
         
@@ -429,8 +426,6 @@
         
         @param env environment settings (dictionary)
         """
-##        self.__sendCommand('{0}{1}\n'.format(
-##            DebugProtocol.RequestEnv, str(env)))
         self.__sendJsonCommand("RequestEnvironment", {"environment": env})
     
     def remoteLoad(self, fn, argv, wd, traceInterpreter=False,
@@ -454,12 +449,6 @@
         
         wd = self.translate(wd, False)
         fn = self.translate(os.path.abspath(fn), False)
-##        self.__sendCommand('{0}{1}\n'.format(
-##            DebugProtocol.RequestForkMode, repr((autoFork, forkChild))))
-##        self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
-##            DebugProtocol.RequestLoad, wd, fn,
-##            str(Utilities.parseOptionString(argv)),
-##            traceInterpreter))
         self.__sendJsonCommand("RequestLoad", {
             "workdir": wd,
             "filename": fn,
@@ -484,11 +473,6 @@
         
         wd = self.translate(wd, False)
         fn = self.translate(os.path.abspath(fn), False)
-##        self.__sendCommand('{0}{1}\n'.format(
-##            DebugProtocol.RequestForkMode, repr((autoFork, forkChild))))
-##        self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
-##            DebugProtocol.RequestRun, wd, fn,
-##            str(Utilities.parseOptionString(argv))))
         self.__sendJsonCommand("RequestRun", {
             "workdir": wd,
             "filename": fn,
@@ -511,10 +495,6 @@
         
         wd = self.translate(wd, False)
         fn = self.translate(os.path.abspath(fn), False)
-##        self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format(
-##            DebugProtocol.RequestCoverage, wd, fn,
-##            str(Utilities.parseOptionString(argv)),
-##            erase))
         self.__sendJsonCommand("RequestCoverage", {
             "workdir": wd,
             "filename": fn,
@@ -536,9 +516,6 @@
         
         wd = self.translate(wd, False)
         fn = self.translate(os.path.abspath(fn), False)
-##        self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
-##            DebugProtocol.RequestProfile, wd, fn,
-##            str(Utilities.parseOptionString(argv)), erase))
         self.__sendJsonCommand("RequestProfile", {
             "workdir": wd,
             "filename": fn,
@@ -553,8 +530,6 @@
         @param stmt the Python statement to execute (string). It
               should not have a trailing newline.
         """
-##        self.__sendCommand('{0}\n'.format(stmt))
-##        self.__sendCommand(DebugProtocol.RequestOK + '\n')
         self.__sendJsonCommand("ExecuteStatement", {
             "statement": stmt,
         })
@@ -563,28 +538,24 @@
         """
         Public method to single step the debugged program.
         """
-##        self.__sendCommand(DebugProtocol.RequestStep + '\n')
         self.__sendJsonCommand("RequestStep", {})
 
     def remoteStepOver(self):
         """
         Public method to step over the debugged program.
         """
-##        self.__sendCommand(DebugProtocol.RequestStepOver + '\n')
         self.__sendJsonCommand("RequestStepOver", {})
 
     def remoteStepOut(self):
         """
         Public method to step out the debugged program.
         """
-##        self.__sendCommand(DebugProtocol.RequestStepOut + '\n')
         self.__sendJsonCommand("RequestStepOut", {})
 
     def remoteStepQuit(self):
         """
         Public method to stop the debugged program.
         """
-##        self.__sendCommand(DebugProtocol.RequestStepQuit + '\n')
         self.__sendJsonCommand("RequestStepQuit", {})
 
     def remoteContinue(self, special=False):
@@ -593,8 +564,6 @@
         
         @param special flag indicating a special continue operation
         """
-##        self.__sendCommand('{0}{1:d}\n'.format(
-##            DebugProtocol.RequestContinue, special))
         self.__sendJsonCommand("RequestContinue", {
             "special": special,
         })
@@ -610,9 +579,6 @@
         @param cond condition of the breakpoint (string)
         @param temp flag indicating a temporary breakpoint (boolean)
         """
-##        fn = self.translate(fn, False)
-##        self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format(
-##            DebugProtocol.RequestBreak, fn, line, temp, set, cond))
         self.__sendJsonCommand("RequestBreakpoint", {
             "filename": self.translate(fn, False),
             "line": line,
@@ -630,9 +596,6 @@
         @param enable flag indicating enabling or disabling a breakpoint
             (boolean)
         """
-##        fn = self.translate(fn, False)
-##        self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
-##            DebugProtocol.RequestBreakEnable, fn, line, enable))
         self.__sendJsonCommand("RequestBreakpointEnable", {
             "filename": self.translate(fn, False),
             "line": line,
@@ -647,9 +610,6 @@
         @param line linenumber of the breakpoint (int)
         @param count number of occurrences to ignore (int)
         """
-##        fn = self.translate(fn, False)
-##        self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
-##            DebugProtocol.RequestBreakIgnore, fn, line, count))
         self.__sendJsonCommand("RequestBreakpointIgnore", {
             "filename": self.translate(fn, False),
             "line": line,
@@ -666,8 +626,6 @@
         @param temp flag indicating a temporary watch expression (boolean)
         """
         # cond is combination of cond and special (s. watch expression viewer)
-##        self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format(
-##            DebugProtocol.RequestWatch, cond, temp, set))
         self.__sendJsonCommand("RequestWatch", {
             "temporary": temp,
             "setWatch": setWatch,
@@ -683,8 +641,6 @@
             (boolean)
         """
         # cond is combination of cond and special (s. watch expression viewer)
-##        self.__sendCommand('{0}{1},{2:d}\n'.format(
-##            DebugProtocol.RequestWatchEnable, cond, enable))
         self.__sendJsonCommand("RequestWatchEnable", {
             "condition": cond,
             "enable": enable,
@@ -699,8 +655,6 @@
         @param count number of occurrences to ignore (int)
         """
         # cond is combination of cond and special (s. watch expression viewer)
-##        self.__sendCommand('{0}{1},{2:d}\n'.format(
-##            DebugProtocol.RequestWatchIgnore, cond, count))
         self.__sendJsonCommand("RequestWatchIgnore", {
             "condition": cond,
             "count": count,
@@ -712,7 +666,6 @@
         
         @param s the raw input (string)
         """
-##        self.__sendCommand(s + '\n')
         self.__sendJsonCommand("RawInput", {
             "input": s,
         })
@@ -721,7 +674,6 @@
         """
         Public method to request the list of threads from the client.
         """
-##        self.__sendCommand('{0}\n'.format(DebugProtocol.RequestThreadList))
         self.__sendJsonCommand("RequestThreadList", {})
         
     def remoteSetThread(self, tid):
@@ -730,8 +682,6 @@
         
         @param tid id of the thread (integer)
         """
-##        self.__sendCommand('{0}{1:d}\n'.format(
-##            DebugProtocol.RequestThreadSet, tid))
         self.__sendJsonCommand("RequestThreadSet", {
             "threadID": tid,
         })
@@ -744,8 +694,6 @@
         @param filter list of variable types to filter out (list of int)
         @param framenr framenumber of the variables to retrieve (int)
         """
-##        self.__sendCommand('{0}{1:d}, {2:d}, {3}\n'.format(
-##            DebugProtocol.RequestVariables, framenr, scope, str(filter)))
         self.__sendJsonCommand("RequestVariables", {
             "frameNumber": framenr,
             "scope": scope,
@@ -761,9 +709,6 @@
         @param var list encoded name of variable to retrieve (string)
         @param framenr framenumber of the variables to retrieve (int)
         """
-##        self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format(
-##            DebugProtocol.RequestVariable, str(var), framenr, scope,
-##            str(filter)))
         self.__sendJsonCommand("RequestVariable", {
             "variable": var,
             "frameNumber": framenr,
@@ -778,8 +723,6 @@
         @param scope the scope of the variables (0 = local, 1 = global)
         @param filter regexp string for variable names to filter out (string)
         """
-##        self.__sendCommand('{0}{1:d}, "{2}"\n'.format(
-##            DebugProtocol.RequestSetFilter, scope, filter))
         self.__sendJsonCommand("RequestSetFilter", {
             "scope": scope,
             "filter": filter,
@@ -791,49 +734,20 @@
         
         @param on flag indicating to enable the call trace function (boolean)
         """
-##        if on:
-##            cmd = "on"
-##        else:
-##            cmd = "off"
-##        self.__sendCommand('{0}{1}\n'.format(
-##            DebugProtocol.RequestCallTrace, cmd))
         self.__sendJsonCommand("RequestCallTrace", {
             "enable": on,
         })
     
-##    def remoteEval(self, arg):
-##        """
-##        Public method to evaluate arg in the current context of the debugged
-##        program.
-##        
-##        @param arg the arguments to evaluate (string)
-##        """
-####        self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg))
-##        self.__sendJsonCommand("RequestEval", {
-##            "argument": arg,
-##        })
-##    
-##    def remoteExec(self, stmt):
-##        """
-##        Public method to execute stmt in the current context of the debugged
-##        program.
-##        
-##        @param stmt statement to execute (string)
-##        """
-##        self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt))
-##    
     def remoteBanner(self):
         """
         Public slot to get the banner info of the remote client.
         """
-##        self.__sendCommand(DebugProtocol.RequestBanner + '\n')
         self.__sendJsonCommand("RequestBanner", {})
     
     def remoteCapabilities(self):
         """
         Public slot to get the debug clients capabilities.
         """
-##        self.__sendCommand(DebugProtocol.RequestCapabilities + '\n')
         self.__sendJsonCommand("RequestCapabilities", {})
     
     def remoteCompletion(self, text):
@@ -843,8 +757,6 @@
         
         @param text the text to be completed (string)
         """
-##        self.__sendCommand("{0}{1}\n".format(
-##            DebugProtocol.RequestCompletion, text))
         self.__sendJsonCommand("RequestCompletion", {
             "text": text,
         })
@@ -868,9 +780,6 @@
         self.__scriptName = os.path.abspath(fn)
         
         fn = self.translate(os.path.abspath(fn), False)
-##        self.__sendCommand('{0}{1}|{2}|{3}|{4}|{5:d}|{6}|{7:d}\n'.format(
-##            DebugProtocol.RequestUTPrepare, fn, tn, tfn, str(failed),
-##            cov, covname, coverase))
         self.__sendJsonCommand("RequestUTPrepare", {
             "filename": fn,
             "testname": tn,
@@ -885,14 +794,12 @@
         """
         Public method to start a unittest run.
         """
-##        self.__sendCommand('{0}\n'.format(DebugProtocol.RequestUTRun))
         self.__sendJsonCommand("RequestUTRun", {})
     
     def remoteUTStop(self):
         """
         Public method to stop a unittest run.
         """
-##        self.__sendCommand('{0}\n'.format(DebugProtocol.RequestUTStop))
         self.__sendJsonCommand("RequestUTStop", {})
     
     def __askForkTo(self):
@@ -908,12 +815,10 @@
             selections,
             0, False)
         if not ok or res == selections[0]:
-##            self.__sendCommand(DebugProtocol.ResponseForkTo + 'parent\n')
             self.__sendJsonCommand("ResponseForkTo", {
                 "target": "parent",
             })
         else:
-##            self.__sendCommand(DebugProtocol.ResponseForkTo + 'child\n')
             self.__sendJsonCommand("ResponseForkTo", {
                 "target": "child",
             })
@@ -928,263 +833,20 @@
                 line = self.codec.toUnicode(qs)
             else:
                 line = bytes(qs).decode()
-##            if line.endswith(EOT):
-##                line = line[:-len(EOT)]
-##                if not line:
-##                    continue
             
 ##            print("Server: ", line)          ##debug
             
-##            if line.startswith("{") and "jsonrpc" in line:
             self.__handleJsonCommand(line)
             continue
-##            
-##            eoc = line.find('<') + 1
-##            
-##            # Deal with case where user has written directly to stdout
-##            # or stderr, but not line terminated and we stepped over the
-##            # write call, in that case the >line< will not be the first
-##            # string read from the socket...
-##            boc = line.find('>')
-##            if boc > 0 and eoc > boc:
-##                self.debugServer.signalClientOutput(line[:boc])
-##                line = line[boc:]
-##                eoc = line.find('<') + 1
-##                boc = line.find('>')
-##            
-##            self.debugServer.signalClientOutput(line)
-##            if boc >= 0 and eoc > boc:
-##                resp = line[boc:eoc]
-##                
-##                if resp == DebugProtocol.ResponseLine or \
-##                   resp == DebugProtocol.ResponseStack:
-##                    stack = eval(line[eoc:-1])
-##                    for s in stack:
-##                        s[0] = self.translate(s[0], True)
-##                    cf = stack[0]
-##                    if self.__autoContinue:
-##                        self.__autoContinue = False
-##                        QTimer.singleShot(0, self.remoteContinue)
-##                    else:
-##                        self.debugServer.signalClientLine(
-##                            cf[0], int(cf[1]),
-##                            resp == DebugProtocol.ResponseStack)
-##                        self.debugServer.signalClientStack(stack)
-##                    continue
-##                
-##                if resp == DebugProtocol.CallTrace:
-##                    event, fromStr, toStr = line[eoc:-1].split("@@")
-##                    isCall = event.lower() == "c"
-##                    fromFile, fromLineno, fromFunc = fromStr.rsplit(":", 2)
-##                    toFile, toLineno, toFunc = toStr.rsplit(":", 2)
-##                    self.debugServer.signalClientCallTrace(
-##                        isCall,
-##                        fromFile, fromLineno, fromFunc,
-##                        toFile, toLineno, toFunc)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseThreadList:
-##                    currentId, threadList = eval(line[eoc:-1])
-##                    self.debugServer.signalClientThreadList(
-##                        currentId, threadList)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseThreadSet:
-##                    self.debugServer.signalClientThreadSet()
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseVariables:
-##                    vlist = eval(line[eoc:-1])
-##                    scope = vlist[0]
-##                    try:
-##                        variables = vlist[1:]
-##                    except IndexError:
-##                        variables = []
-##                    self.debugServer.signalClientVariables(scope, variables)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseVariable:
-##                    vlist = eval(line[eoc:-1])
-##                    scope = vlist[0]
-##                    try:
-##                        variables = vlist[1:]
-##                    except IndexError:
-##                        variables = []
-##                    self.debugServer.signalClientVariable(scope, variables)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseOK:
-##                    self.debugServer.signalClientStatement(False)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseContinue:
-##                    self.debugServer.signalClientStatement(True)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseException:
-##                    exc = line[eoc:-1]
-##                    exc = self.translate(exc, True)
-##                    try:
-##                        exclist = eval(exc)
-##                        exctype = exclist[0]
-##                        excmessage = exclist[1]
-##                        stack = exclist[2:]
-##                        if stack and stack[0] and stack[0][0] == "<string>":
-##                            for stackEntry in stack:
-##                                if stackEntry[0] == "<string>":
-##                                    stackEntry[0] = self.__scriptName
-##                                else:
-##                                    break
-##                    except (IndexError, ValueError, SyntaxError):
-##                        exctype = None
-##                        excmessage = ''
-##                        stack = []
-##                    self.debugServer.signalClientException(
-##                        exctype, excmessage, stack)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseSyntax:
-##                    exc = line[eoc:-1]
-##                    exc = self.translate(exc, True)
-##                    try:
-##                        message, (fn, ln, cn) = eval(exc)
-##                        if fn is None:
-##                            fn = ''
-##                    except (IndexError, ValueError):
-##                        message = None
-##                        fn = ''
-##                        ln = 0
-##                        cn = 0
-##                    if cn is None:
-##                        cn = 0
-##                    self.debugServer.signalClientSyntaxError(
-##                        message, fn, ln, cn)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseSignal:
-##                    sig = line[eoc:-1]
-##                    sig = self.translate(sig, True)
-##                    message, (fn, ln, func, args) = eval(sig)
-##                    self.debugServer.signalClientSignal(
-##                        message, fn, ln, func, args)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseExit:
-##                    self.__scriptName = ""
-##                    self.debugServer.signalClientExit(line[eoc:-1])
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseClearBreak:
-##                    fn, lineno = line[eoc:-1].split(',')
-##                    lineno = int(lineno)
-##                    fn = self.translate(fn, True)
-##                    self.debugServer.signalClientClearBreak(fn, lineno)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseBPConditionError:
-##                    fn, lineno = line[eoc:-1].split(',')
-##                    lineno = int(lineno)
-##                    fn = self.translate(fn, True)
-##                    self.debugServer.signalClientBreakConditionError(
-##                        fn, lineno)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseClearWatch:
-##                    cond = line[eoc:-1]
-##                    self.debugServer.signalClientClearWatch(cond)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseWPConditionError:
-##                    cond = line[eoc:-1]
-##                    self.debugServer.signalClientWatchConditionError(cond)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseRaw:
-##                    prompt, echo = eval(line[eoc:-1])
-##                    self.debugServer.signalClientRawInput(prompt, echo)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseBanner:
-##                    version, platform, dbgclient = eval(line[eoc:-1])
-##                    self.debugServer.signalClientBanner(
-##                        version, platform, dbgclient)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseCapabilities:
-##                    cap, clType = eval(line[eoc:-1])
-##                    self.clientCapabilities = cap
-##                    self.debugServer.signalClientCapabilities(cap, clType)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseCompletion:
-##                    clstring, text = line[eoc:-1].split('||')
-##                    cl = eval(clstring)
-##                    self.debugServer.signalClientCompletionList(cl, text)
-##                    continue
-##                
-##                if resp == DebugProtocol.PassiveStartup:
-##                    fn, exc = line[eoc:-1].split('|')
-##                    exc = bool(exc)
-##                    fn = self.translate(fn, True)
-##                    self.debugServer.passiveStartUp(fn, exc)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTPrepared:
-##                    res, exc_type, exc_value = eval(line[eoc:-1])
-##                    self.debugServer.clientUtPrepared(res, exc_type, exc_value)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTStartTest:
-##                    testname, doc = eval(line[eoc:-1])
-##                    self.debugServer.clientUtStartTest(testname, doc)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTStopTest:
-##                    self.debugServer.clientUtStopTest()
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTTestFailed:
-##                    testname, traceback, id = eval(line[eoc:-1])
-##                    self.debugServer.clientUtTestFailed(
-##                        testname, traceback, id)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTTestErrored:
-##                    testname, traceback, id = eval(line[eoc:-1])
-##                    self.debugServer.clientUtTestErrored(
-##                        testname, traceback, id)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTTestSkipped:
-##                    testname, reason, id = eval(line[eoc:-1])
-##                    self.debugServer.clientUtTestSkipped(testname, reason, id)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTTestFailedExpected:
-##                    testname, traceback, id = eval(line[eoc:-1])
-##                    self.debugServer.clientUtTestFailedExpected(
-##                        testname, traceback, id)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTTestSucceededUnexpected:
-##                    testname, id = eval(line[eoc:-1])
-##                    self.debugServer.clientUtTestSucceededUnexpected(
-##                        testname, id)
-##                    continue
-##                
-##                if resp == DebugProtocol.ResponseUTFinished:
-##                    self.debugServer.clientUtFinished()
-##                    continue
-##                
-##                if resp == DebugProtocol.RequestForkTo:
-##                    self.__askForkTo()
-##                    continue
-##            
-##            self.debugServer.signalClientOutput(line)
     
     def __handleJsonCommand(self, jsonStr):
         """
-        Private method to handle a command serialized as a JSON string.
+        Private method to handle a command or response serialized as a
+        JSON string.
+        
+        @param jsonStr string containing the command or response received
+            from the debug backend
+        @type str
         """
         import json
         
@@ -1192,7 +854,7 @@
             commandDict = json.loads(jsonStr.strip())
         except json.JSONDecodeError as err:
             # TODO: implement real error handling
-##            print(str(err))
+            ##print(str(err))
             return
         
         method = commandDict["method"]

eric ide

mercurial