aboutsummaryrefslogtreecommitdiffstats
path: root/functest/core/feature.py
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-12-26 09:17:13 +0000
committerLinda Wang <wangwulin@huawei.com>2017-12-27 06:19:23 +0000
commit77d598a882652801b2ddf480c34d896f745657dc (patch)
tree9e32d7b531e3c0e257881250960656524ac2c2e0 /functest/core/feature.py
parentc411e0a16b804792c1b34cc819618e1bfbca3d9a (diff)
Execute feature command by subprocess directly
Change-Id: I77e86af4e96310c6520d743e4d16c9a7b2e9adf5 Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest/core/feature.py')
-rw-r--r--functest/core/feature.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/functest/core/feature.py b/functest/core/feature.py
index 2dc3ccbd..3200dad8 100644
--- a/functest/core/feature.py
+++ b/functest/core/feature.py
@@ -14,10 +14,10 @@ helpers to run any python method or any bash command.
"""
import logging
+import subprocess
import time
import functest.core.testcase as base
-import functest.utils.functest_utils as ft_utils
from functest.utils.constants import CONST
__author__ = ("Serena Feng <feng.xiaowei@zte.com.cn>, "
@@ -123,9 +123,12 @@ class BashFeature(Feature):
ret = -1
try:
cmd = kwargs["cmd"]
- ret = ft_utils.execute_command(cmd, output_file=self.result_file)
+ with open(self.result_file, 'w+') as f_stdout:
+ proc = subprocess.Popen(cmd.split(), stdout=f_stdout,
+ stderr=subprocess.STDOUT)
+ ret = proc.wait()
+ if ret != 0:
+ self.__logger.error("Execute command: %s failed", cmd)
except KeyError:
self.__logger.error("Please give cmd as arg. kwargs: %s", kwargs)
- except Exception: # pylint: disable=broad-except
- self.__logger.exception("Execute cmd: %s failed", cmd)
return ret