diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-11-28 22:37:17 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-12-01 11:36:58 +0100 |
commit | eae8283aaadeb77884406ded028f2e414659c3b3 (patch) | |
tree | e83242479429433f05005dbb7c9e762b44c5b3f7 /xtesting/core/feature.py | |
parent | 0afe15823d98871a09ae88840a2d3538137299a8 (diff) |
Set shell=True in subprocess.check_call
It allows running multiple shell instructions (see third).
Change-Id: I132813c51d42f0fb4bc729d315c468d426f2fb3c
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit f99cef18b6dd3eff6703c4d748fae415fea78ae2)
Diffstat (limited to 'xtesting/core/feature.py')
-rw-r--r-- | xtesting/core/feature.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/xtesting/core/feature.py b/xtesting/core/feature.py index 86215515..2cb36bd6 100644 --- a/xtesting/core/feature.py +++ b/xtesting/core/feature.py @@ -99,17 +99,14 @@ class BashFeature(Feature): 0 if cmd returns 0, -1 otherwise. """ - ret = -1 try: cmd = kwargs["cmd"] with open(self.result_file, 'w+') as f_stdout: - proc = subprocess.Popen(cmd.split(), stdout=f_stdout, - stderr=subprocess.STDOUT) - ret = proc.wait() - self.__logger.info( - "Test result is stored in '%s'", self.result_file) - if ret != 0: - self.__logger.error("Execute command: %s failed", cmd) + subprocess.check_call( + cmd, shell=True, stdout=f_stdout, stderr=subprocess.STDOUT) + return 0 except KeyError: self.__logger.error("Please give cmd as arg. kwargs: %s", kwargs) - return ret + except subprocess.CalledProcessError: + self.__logger.error("Execute command: %s failed", cmd) + return -1 |