diff -r eb1b3e0577e4 -r b6cbdba69967 Debugger/DebuggerInterfacePython3.py --- a/Debugger/DebuggerInterfacePython3.py Thu Sep 01 20:03:50 2016 +0200 +++ b/Debugger/DebuggerInterfacePython3.py Fri Sep 02 19:14:41 2016 +0200 @@ -19,7 +19,7 @@ from E5Gui.E5Application import e5App from E5Gui import E5MessageBox -from . import DebugProtocol +##from . import DebugProtocol from . import DebugClientCapabilities import Preferences @@ -29,6 +29,7 @@ ClientDefaultCapabilities = DebugClientCapabilities.HasAll +##EOT = '>EOT<\n' class DebuggerInterfacePython3(QObject): @@ -884,13 +885,15 @@ """ Public method to start a unittest run. """ - self.__sendCommand('{0}\n'.format(DebugProtocol.RequestUTRun)) +## 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.__sendCommand('{0}\n'.format(DebugProtocol.RequestUTStop)) + self.__sendJsonCommand("RequestUTStop", {}) def __askForkTo(self): """ @@ -905,9 +908,15 @@ selections, 0, False) if not ok or res == selections[0]: - self.__sendCommand(DebugProtocol.ResponseForkTo + 'parent\n') +## self.__sendCommand(DebugProtocol.ResponseForkTo + 'parent\n') + self.__sendJsonCommand("ResponseForkTo", { + "target": "parent", + }) else: - self.__sendCommand(DebugProtocol.ResponseForkTo + 'child\n') +## self.__sendCommand(DebugProtocol.ResponseForkTo + 'child\n') + self.__sendJsonCommand("ResponseForkTo", { + "target": "child", + }) def __parseClientLine(self): """ @@ -919,33 +928,34 @@ line = self.codec.toUnicode(qs) else: line = bytes(qs).decode() - if line.endswith(DebugProtocol.EOT): - line = line[:-len(DebugProtocol.EOT)] - if not line: - continue +## 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('>') - - if boc >= 0 and eoc > boc: - resp = line[boc:eoc] - +## 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]) @@ -1124,53 +1134,53 @@ ## 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) +## 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): """ @@ -1182,13 +1192,16 @@ 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"] params = commandDict["params"] - if method in ["ResponseLine", "ResponseStack"]: + if method == "ClientOutput": + self.debugServer.signalClientOutput(params["text"]) + + elif method in ["ResponseLine", "ResponseStack"]: for s in params["stack"]: s[0] = self.translate(s[0], True) cf = params["stack"][0] @@ -1200,9 +1213,8 @@ cf[0], int(cf[1]), method == "ResponseStack") self.debugServer.signalClientStack(params["stack"]) - return - if method == "CallTrace": + elif method == "CallTrace": isCall = params["event"].lower() == "c" fromFile, fromLineno, fromFunc = params["from"].rsplit(":", 2) toFile, toLineno, toFunc = params["to"].rsplit(":", 2) @@ -1210,75 +1222,61 @@ isCall, fromFile, fromLineno, fromFunc, toFile, toLineno, toFunc) - return - if method == "ResponseVariables": + elif method == "ResponseVariables": self.debugServer.signalClientVariables( params["scope"], params["variables"]) - return - if method == "ResponseVariable": + elif method == "ResponseVariable": self.debugServer.signalClientVariable( params["scope"], [params["variable"]] + params["variables"]) - return - if method == "ResponseThreadList": + elif method == "ResponseThreadList": self.debugServer.signalClientThreadList( params["currentID"], params["threadList"]) - return - if method == "ResponseThreadSet": + elif method == "ResponseThreadSet": self.debugServer.signalClientThreadSet() - return - if method == "ResponseCapabilities": + elif method == "ResponseCapabilities": self.clientCapabilities = params["capabilities"] self.debugServer.signalClientCapabilities( params["capabilities"], params["clientType"]) - return - if method == "ResponseBanner": + elif method == "ResponseBanner": self.debugServer.signalClientBanner( params["version"], params["platform"], params["dbgclient"]) - return - if method == "ResponseOK": + elif method == "ResponseOK": self.debugServer.signalClientStatement(False) - return - if method == "ResponseContinue": + elif method == "ResponseContinue": self.debugServer.signalClientStatement(True) - return - if method == "RequestRaw": + elif method == "RequestRaw": self.debugServer.signalClientRawInput( params["prompt"], params["echo"]) - return - if method == "ResponseBPConditionError": + elif method == "ResponseBPConditionError": params["filename"] = self.translate(params["filename"], True) self.debugServer.signalClientBreakConditionError( params["filename"], params["line"]) - return - if method == "ResponseClearBreakpoint": + elif method == "ResponseClearBreakpoint": params["filename"] = self.translate(params["filename"], True) self.debugServer.signalClientClearBreak( params["filename"], params["line"]) - return - if method == "ResponseWatchConditionError": + elif method == "ResponseWatchConditionError": self.debugServer.signalClientWatchConditionError( params["condition"]) - return - if method == "ResponseClearWatch": + elif method == "ResponseClearWatch": self.debugServer.signalClientClearWatch(params["condition"]) - return - if method == "ResponseException": + elif method == "ResponseException": if params: exctype = params["type"] excmessage = params["message"] @@ -1293,45 +1291,73 @@ else: break else: - exctype = None + exctype = '' excmessage = '' stack = [] self.debugServer.signalClientException( exctype, excmessage, stack) - return - if method == "ResponseSyntax": + elif method == "ResponseSyntax": self.debugServer.signalClientSyntaxError( params["message"], self.translate(params["filename"], True), params["linenumber"], params["characternumber"]) - return - if method == "ResponseSignal": + elif method == "ResponseSignal": self.debugServer.signalClientSignal( params["message"], self.translate(params["filename"], True), params["linenumber"], params["function"], params["arguments"]) - return - if method == "ResponseExit": + elif method == "ResponseExit": self.__scriptName = "" self.debugServer.signalClientExit(params["status"]) - return + if params["message"]: + self.debugServer.signalClientOutput(params["message"]) - if method == "PassiveStartup": + elif method == "PassiveStartup": self.debugServer.passiveStartUp( self.translate(params["filename"], True), params["exceptions"]) - return - if method == "ResponseCompletion": + elif method == "ResponseCompletion": self.debugServer.signalClientCompletionList( params["completions"], params["text"]) - return - if method == "ResponseUTPrepared": + elif method == "ResponseUTPrepared": self.debugServer.clientUtPrepared( params["count"], params["exception"], params["message"]) - return + + elif method == "ResponseUTFinished": + self.debugServer.clientUtFinished() + + elif method == "ResponseUTStartTest": + self.debugServer.clientUtStartTest( + params["testname"], params["description"]) + + elif method == "ResponseUTStopTest": + self.debugServer.clientUtStopTest() + + elif method == "ResponseUTTestFailed": + self.debugServer.clientUtTestFailed( + params["testname"], params["traceback"], params["id"]) + + elif method == "ResponseUTTestErrored": + self.debugServer.clientUtTestErrored( + params["testname"], params["traceback"], params["id"]) + + elif method == "ResponseUTTestSkipped": + self.debugServer.clientUtTestSkipped( + params["testname"], params["reason"], params["id"]) + + elif method == "ResponseUTTestFailedExpected": + self.debugServer.clientUtTestFailedExpected( + params["testname"], params["traceback"], params["id"]) + + elif method == "ResponseUTTestSucceededUnexpected": + self.debugServer.clientUtTestSucceededUnexpected( + params["testname"], params["id"]) + + elif method == "RequestForkTo": + self.__askForkTo() def __sendCommand(self, cmd): """