diff --git a/tripleoclient/tests/test_utils.py b/tripleoclient/tests/test_utils.py index 76398ea19..94972a666 100644 --- a/tripleoclient/tests/test_utils.py +++ b/tripleoclient/tests/test_utils.py @@ -559,17 +559,6 @@ class TestRunCommandAndLog(TestCase): self.mock_logger.warning.assert_has_calls(self.log_calls, any_order=False) - def test_success_no_retcode(self): - run = utils.run_command_and_log(self.mock_logger, self.cmd, - retcode_only=False) - self.mock_popen.assert_called_once_with(self.cmd, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - shell=False, - cwd=None, env=None) - self.assertEqual(run, self.mock_process) - self.mock_logger.warning.assert_not_called() - class TestWaitForStackUtil(TestCase): def setUp(self): diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index e57920ac8..9caffeae1 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -2141,7 +2141,7 @@ def bulk_symlink(log, src, dst, tmpd='/tmp'): os.rename(tmpf, os.path.join(dst, obj)) -def run_command_and_log(log, cmd, cwd=None, env=None, retcode_only=True): +def run_command_and_log(log, cmd, cwd=None, env=None): """Run command and log output :param log: logger instance for logging @@ -2150,33 +2150,28 @@ def run_command_and_log(log, cmd, cwd=None, env=None, retcode_only=True): :param cmd: command in list form :type cmd: List - :param cwd: current worknig directory for execution + :param cwd: current working directory for execution :type cmd: String :param env: modified environment for command run :type env: List - - :param retcode_only: Returns only retcode instead or proc objec - :type retcdode_only: Boolean """ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, cwd=cwd, env=env) - if retcode_only: - while True: - try: - line = proc.stdout.readline() - except StopIteration: - break - if line != b'': - if isinstance(line, bytes): - line = line.decode('utf-8') - log.warning(line.rstrip()) - else: - break - proc.stdout.close() - return proc.wait() - return proc + while True: + try: + line = proc.stdout.readline() + except StopIteration: + break + if line != b'': + if isinstance(line, bytes): + line = line.decode('utf-8') + log.warning(line.rstrip()) + else: + break + proc.stdout.close() + return proc.wait() def build_prepare_env(environment_files, environment_directories):