Fix readline() handling for partial lines
authorClifford Wolf <clifford@clifford.at>
Mon, 13 Feb 2017 15:59:34 +0000 (16:59 +0100)
committerClifford Wolf <clifford@clifford.at>
Mon, 13 Feb 2017 15:59:34 +0000 (16:59 +0100)
sbysrc/sby_core.py

index d53d7d6b2082f349e1cffa4c7cdcc7f281e4877d..a1aaec351473f9dfeca85eb4a469d2d942f064a8 100644 (file)
@@ -35,6 +35,7 @@ class SbyTask:
         self.logfile = logfile
         self.noprintregex = None
         self.notify = []
+        self.linebuffer = ""
 
         for dep in self.deps:
             dep.register_dep(self)
@@ -95,7 +96,11 @@ class SbyTask:
         while True:
             outs = self.p.stdout.readline().decode("utf-8")
             if len(outs) == 0: break
-            outs = outs.strip()
+            if outs[-1] != '\n':
+                self.linebuffer += outs
+                break
+            outs = (self.linebuffer + outs).strip()
+            self.linebuffer = ""
             if len(outs) == 0: continue
             if self.noprintregex is None or not self.noprintregex.match(outs):
                 self.job.log("%s: %s" % (self.info, outs))