DebugClients/Python/AsyncFile.py

changeset 5966
3325ecd87c7c
parent 5943
10ad861d21f2
child 6048
82ad8ec9548c
--- a/DebugClients/Python/AsyncFile.py	Thu Nov 09 18:31:34 2017 +0100
+++ b/DebugClients/Python/AsyncFile.py	Sat Nov 11 18:44:04 2017 +0100
@@ -184,7 +184,25 @@
         if size >= 0:
             buf = buf[:size]
         return buf
-
+    
+    def readCommand(self):
+        """
+        Public method to read a length prefixed command string.
+        
+        @return command string
+        @rtype str
+        """
+        # The command string is prefixed by a 9 character long length field.
+        length = self.sock.recv(9)
+        length = int(length)
+        data = b''
+        while len(data) < length:
+            newData = self.sock.recv(length - len(data))
+            data += newData
+        
+        # step 2: convert the data
+        return data.decode('utf8', 'backslashreplace')
+    
     def readline_p(self, size=-1):
         """
         Public method to read a line from this file.

eric ide

mercurial