Debugger/DebuggerInterfacePython.py

changeset 5966
3325ecd87c7c
parent 5964
066e6c78a367
child 6048
82ad8ec9548c
equal deleted inserted replaced
5965:b8d53f4149c8 5966:3325ecd87c7c
405 """ 405 """
406 Public slot to flush the queue. 406 Public slot to flush the queue.
407 """ 407 """
408 # Send commands that were waiting for the connection. 408 # Send commands that were waiting for the connection.
409 for cmd in self.queue: 409 for cmd in self.queue:
410 self.qsock.write(cmd.encode('utf8', 'backslashreplace')) 410 self.__writeJsonCommandToSocket(cmd)
411 411
412 self.queue = [] 412 self.queue = []
413 413
414 def shutdown(self): 414 def shutdown(self):
415 """ 415 """
1103 "method": command, 1103 "method": command,
1104 "params": params, 1104 "params": params,
1105 } 1105 }
1106 cmd = json.dumps(commandDict) + '\n' 1106 cmd = json.dumps(commandDict) + '\n'
1107 if self.qsock is not None: 1107 if self.qsock is not None:
1108 self.qsock.write(cmd.encode('utf8', 'backslashreplace')) 1108 self.__writeJsonCommandToSocket(cmd)
1109 else: 1109 else:
1110 self.queue.append(cmd) 1110 self.queue.append(cmd)
1111
1112 def __writeJsonCommandToSocket(self, cmd):
1113 """
1114 Private method to write a JSON command to the socket.
1115
1116 @param cmd JSON command to be sent
1117 @type str
1118 """
1119 data = cmd.encode('utf8', 'backslashreplace')
1120 length = "{0:09d}".format(len(data))
1121 self.qsock.write(length.encode() + data)
1122 self.qsock.flush()
1111 1123
1112 1124
1113 def createDebuggerInterfacePython2(debugServer, passive): 1125 def createDebuggerInterfacePython2(debugServer, passive):
1114 """ 1126 """
1115 Module function to create a debugger interface instance. 1127 Module function to create a debugger interface instance.

eric ide

mercurial