DebugClients/Python3/AsyncFile.py

branch
jsonrpc
changeset 5128
b6cbdba69967
parent 4631
5c1a96925da4
child 5129
e4ab234cf071
--- a/DebugClients/Python3/AsyncFile.py	Thu Sep 01 20:03:50 2016 +0200
+++ b/DebugClients/Python3/AsyncFile.py	Fri Sep 02 19:14:41 2016 +0200
@@ -10,8 +10,6 @@
 
 import socket
 
-from DebugProtocol import EOT
-
 
 def AsyncPendingWrite(file):
     """
@@ -77,7 +75,7 @@
         """
         if n:
             try:
-                buf = "{0!s}{1!s}".format(self.wpending[:n], EOT)
+                buf = self.wpending[:n]
                 try:
                     buf = buf.encode('utf-8', 'backslashreplace')
                 except (UnicodeEncodeError, UnicodeDecodeError):
@@ -295,7 +293,27 @@
         """
         Public method to write a string to the file.
         
-        @param s bytes to be written (string)
+        @param s text to be written (string)
+        """
+        self.__checkMode('w')
+        
+        import json
+        commandDict = {
+            "jsonrpc": "2.0",
+            "method": "ClientOutput",
+            "params": {
+                "text": s,
+            }
+        }
+        cmd = json.dumps(commandDict) + '\n'
+        
+        self.write_p(cmd)
+    
+    def write_p(self, s):
+        """
+        Public method to write a string to the file.
+        
+        @param s text to be written (string)
         @exception socket.error raised to indicate too many send attempts
         """
         self.__checkMode('w')
@@ -317,14 +335,13 @@
             self.wpending += s
         self.__nWrite(self.pendingWrite())
 
-    def writelines(self, list):
+    def writelines(self, lines):
         """
         Public method to write a list of strings to the file.
         
-        @param list the list to be written (list of string)
+        @param lines list of texts to be written (list of string)
         """
-        for l in list:
-            self.write(l)
+        self.write("".join(lines))
 
 #
 # eflag: noqa = M702

eric ide

mercurial