run_task_fix: Fix run_task to provide all output from command 41/14041/1
authorChristian Trautman <ctrautma@redhat.com>
Thu, 12 May 2016 13:26:47 +0000 (09:26 -0400)
committerChristian Trautman <ctrautma@redhat.com>
Thu, 12 May 2016 13:26:47 +0000 (09:26 -0400)
Fix run_task to correctly provide all output from command
sent. Commands that produced longer output would not
return all text.

JIRA: VSPERF-296

Change-Id: I7e501690ffdb7c01f90d524ffbabe65500f62304
Signed-off-by: Christian Trautman <ctrautma@redhat.com>
tools/tasks.py

index dda5217..9816a33 100644 (file)
@@ -86,17 +86,24 @@ def run_task(cmd, logger, msg=None, check_error=False):
 
             for file_d in ret[0]:
                 if file_d == proc.stdout.fileno():
-                    line = proc.stdout.readline()
-                    if settings.getValue('VERBOSITY') == 'debug':
-                        sys.stdout.write(line.decode(my_encoding))
-                    stdout.append(line)
+                    while True:
+                        line = proc.stdout.readline()
+                        if not line:
+                            break
+                        if settings.getValue('VERBOSITY') == 'debug':
+                            sys.stdout.write(line.decode(my_encoding))
+                        stdout.append(line)
                 if file_d == proc.stderr.fileno():
-                    line = proc.stderr.readline()
-                    sys.stderr.write(line.decode(my_encoding))
-                    stderr.append(line)
+                    while True:
+                        line = proc.stderr.readline()
+                        if not line:
+                            break
+                        sys.stderr.write(line.decode(my_encoding))
+                        stderr.append(line)
 
             if proc.poll() is not None:
                 break
+
     except OSError as ex:
         handle_error(ex)
     else: