331 def write(self, s): |
331 def write(self, s): |
332 """ |
332 """ |
333 Public method to write a string to the file. |
333 Public method to write a string to the file. |
334 |
334 |
335 @param s text to be written |
335 @param s text to be written |
336 @type str |
336 @type str, bytes or bytearray |
337 """ |
337 """ |
338 self.__checkMode('w') |
338 self.__checkMode('w') |
|
339 |
|
340 if isinstance(s, (bytes, bytearray)): |
|
341 # convert to string to send it |
|
342 s = repr(s) |
339 |
343 |
340 cmd = prepareJsonCommand("ClientOutput", { |
344 cmd = prepareJsonCommand("ClientOutput", { |
341 "text": s, |
345 "text": s, |
342 }) |
346 }) |
343 self.wpending.append(cmd) |
347 self.wpending.append(cmd) |