Parcourir la source

Fix line buffering when there's UTF-8 in a container's output

Aanand Prasad il y a 12 ans
Parent
commit
059d240824
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      fig/cli/log_printer.py

+ 6 - 1
fig/cli/log_printer.py

@@ -55,10 +55,15 @@ def read_websocket(websocket):
             break
 
 def split_buffer(reader, separator):
+    """
+    Given a generator which yields strings and a separator string,
+    joins all input, splits on the separator and yields each chunk.
+    Requires that each input string is decodable as UTF-8.
+    """
     buffered = ''
 
     for data in reader:
-        lines = (buffered + data).split(separator)
+        lines = (buffered + data.decode('utf-8')).split(separator)
         for line in lines[:-1]:
             yield line + separator
         if len(lines) > 1: