Current output processing reads data and puts them to logging without taking care about eol. This produces ugly and unreadable output like
| checking whether to enable maintainer-specific portions of Makefiles... | no | checking build system type... | i386-redhat-linux-gnu Patch reads output into a buffer which is given to logging after a newline. Signed-off-by: Enrico Scholz <[EMAIL PROTECTED]> --- py/mock/util.py | 46 +++++++++++++++++++++++++++++++++++----------- 1 files changed, 35 insertions(+), 11 deletions(-) diff --git a/py/mock/util.py b/py/mock/util.py index 9f0eb3a..6e3d88e 100644 --- a/py/mock/util.py +++ b/py/mock/util.py @@ -225,33 +225,57 @@ def condPersonality(per=None): def logOutput(fds, logger, returnOutput=1, start=0, timeout=0): output="" done = 0 + input = {} # set all fds to nonblocking for fd in fds: + input[fd] = '' flags = fcntl.fcntl(fd, fcntl.F_GETFL) if not fd.closed: fcntl.fcntl(fd, fcntl.F_SETFL, flags| os.O_NONBLOCK) while not done: - if (time.time() - start)>timeout and timeout!=0: + if timeout!=0 and (time.time() - start)>timeout: 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 == "": + inp = s.read() + if inp == "": done = 1 break - if logger is not None: - for line in input.split("\n"): - if line == '': continue - logger.debug(chomp(line)) - for h in logger.handlers: - h.flush() + if returnOutput: - output += input + output += inp + + if logger is None: + continue + + assert('\n' not in input[s]) + input[s] += inp + if '\n' not in inp: + continue + + lines = input[s].split("\n") + input[s] = lines[len(lines)-1] + del lines[len(lines)-1] + + for line in lines: + if line == '': continue + logger.debug(chomp(line)) + for h in logger.handlers: + h.flush() + + if logger is not None: + for fd in fds: + if input[s]=='': continue + logger.debug(chomp(input[s])) + + for h in logger.handlers: + h.flush() + return output # logger = -- 1.5.4.1 -- Fedora-buildsys-list mailing list Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list