diff options
author | Manuel Buil <mbuil@suse.com> | 2017-02-08 16:52:42 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-02-08 16:52:42 +0000 |
commit | e25bab2e849936c3557c717b05b1b0e92822918b (patch) | |
tree | 6d2c3e3221948e415855496a57bec73e9877a493 | |
parent | 3b90521df996639d44519897823967271306e9de (diff) | |
parent | c94abdd2538b948ccd75a1d1e6386e6e5a1675ec (diff) |
Merge "Simplify run_cmd"
-rw-r--r-- | sfc/lib/utils.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py index a89dc5b5..3238e097 100644 --- a/sfc/lib/utils.py +++ b/sfc/lib/utils.py @@ -27,25 +27,19 @@ FUNCTEST_RESULTS_DIR = os.path.join("home", "opnfv", "functest", "results", "odl-sfc") -def run_cmd(cmd, wdir=None, ignore_stderr=False, ignore_no_output=True): +def run_cmd(cmd): """run given command locally and return commands output if success""" pipe = subprocess.Popen(cmd, shell=True, - stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, cwd=wdir) + stderr=subprocess.PIPE) (output, errors) = pipe.communicate() if output: output = output.strip() - if pipe.returncode < 0: + if pipe.returncode != 0 or len(errors) > 0: + logger.error('FAILED to execute {0}'.format(cmd)) logger.error(errors) - return False - if errors: - logger.error(errors) - return ignore_stderr - - if ignore_no_output and not output: - return True + return None return output |