documentation: Installation prerequisites
[vswitchperf.git] / tools / tasks.py
index dda5217..4179291 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2015 Intel Corporation.
+# Copyright 2015-2017 Intel Corporation.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 import select
 import subprocess
 import logging
-import pexpect
 import threading
 import sys
 import os
 import locale
 import time
+import pexpect
 
 from conf import settings
 from tools import systeminfo
@@ -73,8 +73,8 @@ def run_task(cmd, logger, msg=None, check_error=False):
     if msg:
         logger.info(msg)
 
+    # pylint: disable=too-many-nested-blocks
     logger.debug('%s%s', CMD_PREFIX, ' '.join(cmd))
-
     try:
         proc = subprocess.Popen(map(os.path.expanduser, cmd),
                                 stdout=subprocess.PIPE,
@@ -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: