]> git.ipfire.org Git - pakfire.git/commitdiff
Enable command logger to log empty lines.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 3 Apr 2012 13:51:55 +0000 (15:51 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 3 Apr 2012 13:51:55 +0000 (15:51 +0200)
python/pakfire/chroot.py

index 6001f2ea43bee11270dd5037cb6b4612749f253c..c620fdb8cf1514ecdfae5df8b71f211143304ba5 100644 (file)
@@ -42,32 +42,40 @@ def logOutput(fds, logger, returnOutput=1, start=0, timeout=0):
 
        tail = ""
        while not done:
-               if (time.time() - start)>timeout and timeout!=0:
+               if (time.time() - start) > timeout and timeout != 0:
                        done = 1
                        break
 
-               i_rdy,o_rdy,e_rdy = select.select(fds,[],[],1) 
+               i_rdy, o_rdy, e_rdy = select.select(fds,[],[],1)
+
                for s in i_rdy:
                        # slurp as much input as is ready
                        input = s.read()
+
                        if input == "":
                                done = 1
                                break
+
                        if logger is not None:
                                lines = input.split("\n")
                                if tail:
                                        lines[0] = tail + lines[0]
+
                                # we may not have all of the last line
                                tail = lines.pop()
+
                                for line in lines:
-                                       if line == '': continue
                                        logger.info(line)
+
                                for h in logger.handlers:
                                        h.flush()
+
                        if returnOutput:
                                output += input
+
        if tail and logger is not None:
                logger.info(tail)
+
        return output