--- a/DebugClients/Python/DebugClientBase.py Thu Nov 09 18:31:34 2017 +0100 +++ b/DebugClients/Python/DebugClientBase.py Sat Nov 11 18:44:04 2017 +0100 @@ -187,7 +187,6 @@ """ self.breakpoints = {} self.redirect = True - self.__receiveBuffer = "" # special objects representing the main scripts thread and frame self.mainThread = self @@ -355,23 +354,6 @@ return code - def handleLine(self, line): - """ - Public method to handle the receipt of a complete line. - - It first looks for a valid protocol token at the start of the line. - Thereafter it trys to execute the lines accumulated so far. - - @param line the received line - """ - # Remove any newline. - if line[-1] == '\n': - line = line[:-1] - -## printerr(line) ##debug - - self.handleJsonCommand(line) - def handleJsonCommand(self, jsonStr): """ Public method to handle a command serialized as a JSON string. @@ -379,9 +361,12 @@ @param jsonStr string containing the command received from the IDE @type str """ +## printerr(jsonStr) ##debug + try: commandDict = json.loads(jsonStr.strip()) except (TypeError, ValueError) as err: + printerr("Error handling command: " + jsonStr) printerr(str(err)) return @@ -1031,23 +1016,17 @@ @param stream file like object that has data to be written """ try: - got = stream.readline_p() + self.lockClient() + command = stream.readCommand() + self.unlockClient() except Exception: return - if len(got) == 0: + if len(command) == 0: self.sessionClose() return - - self.__receiveBuffer = self.__receiveBuffer + got - - # Call handleLine for the line if it is complete. - eol = self.__receiveBuffer.find('\n') - while eol >= 0: - line = self.__receiveBuffer[:eol + 1] - self.__receiveBuffer = self.__receiveBuffer[eol + 1:] - self.handleLine(line) - eol = self.__receiveBuffer.find('\n') + + self.handleJsonCommand(command) def writeReady(self, stream): """ @@ -2071,7 +2050,7 @@ redirect = True elif sys.argv[2] == "False": redirect = False - else: + else: try: redirect = int(sys.argv[2]) except (ValueError, IndexError):