DebugClients/Python/AsyncFile.py

branch
maintenance
changeset 6004
548a9ba8c970
parent 5966
3325ecd87c7c
child 6048
82ad8ec9548c
--- a/DebugClients/Python/AsyncFile.py	Sun Nov 19 13:06:01 2017 +0100
+++ b/DebugClients/Python/AsyncFile.py	Sat Dec 02 12:40:22 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