From 9eb2dc48fb1097416a42fe4835274b9c4d8a9ad9 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Tue, 11 Nov 2008 16:49:25 -0600 Subject: Signed-off-by: Mike McLean --- py/mock/util.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'py') diff --git a/py/mock/util.py b/py/mock/util.py index 44b32d6..42f7ba6 100644 --- a/py/mock/util.py +++ b/py/mock/util.py @@ -233,6 +233,7 @@ def logOutput(fds, logger, returnOutput=1, start=0, timeout=0): if not fd.closed: fcntl.fcntl(fd, fcntl.F_SETFL, flags| os.O_NONBLOCK) + tail = "" while not done: if (time.time() - start)>timeout and timeout!=0: done = 1 @@ -246,13 +247,20 @@ def logOutput(fds, logger, returnOutput=1, start=0, timeout=0): done = 1 break if logger is not None: - for line in input.split("\n"): + 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.debug(chomp(line)) + logger.debug(line) for h in logger.handlers: h.flush() if returnOutput: output += input + if tail and logger is not None: + logger.debug(tail) return output # logger = -- cgit