diff --git a/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py b/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py index 0d4fc2b89..df113b4eb 100644 --- a/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py +++ b/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py @@ -889,7 +889,7 @@ class TestDeployUndercloud(TestPluginV1): env ) - @mock.patch('tripleoclient.utils.send_cmdline_erase_sequence') + @mock.patch('tripleoclient.utils.reset_cmdline') @mock.patch('tripleo_common.actions.ansible.' 'write_default_ansible_cfg') # TODO(cjeanner) drop once we have proper oslo.privsep @@ -975,7 +975,7 @@ class TestDeployUndercloud(TestPluginV1): self.assertEqual(mock_killheat.call_count, 2) mock_cmdline.assert_called_once() - @mock.patch('tripleoclient.utils.send_cmdline_erase_sequence') + @mock.patch('tripleoclient.utils.reset_cmdline') @mock.patch('tripleoclient.utils.ansible_symlink') def test_take_action(self, mock_slink, mock_cmdline): mock_slink.side_effect = 'fake-cmd' @@ -988,7 +988,7 @@ class TestDeployUndercloud(TestPluginV1): self.cmd.take_action, parsed_args) mock_cmdline.assert_called_once() - @mock.patch('tripleoclient.utils.send_cmdline_erase_sequence') + @mock.patch('tripleoclient.utils.reset_cmdline') @mock.patch('tripleoclient.v1.tripleo_deploy.Deploy._standalone_deploy', return_value=1) @mock.patch('tripleoclient.utils.ansible_symlink') diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 90f621027..5d97d2eff 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -2034,8 +2034,10 @@ def check_deprecated_service_is_enabled(environment_files): check_file_for_enabled_service(env_file) -def send_cmdline_erase_sequence(): - # Send's an erase in line sequence to the output - # https://www.vt100.net/docs/vt100-ug/chapter3.html#EL - sys.stdout.write(u'\u001b[0K') +def reset_cmdline(): + """Run reset to cleanup cmdline""" + # only try to reset if stdout is a terminal, skip if not (e.g. CI) + if not sys.stdout.isatty(): + return + sys.stdout.write(run_command(['reset', '-I'])) sys.stdout.flush() diff --git a/tripleoclient/v1/tripleo_deploy.py b/tripleoclient/v1/tripleo_deploy.py index c220e271f..2ee4409ff 100644 --- a/tripleoclient/v1/tripleo_deploy.py +++ b/tripleoclient/v1/tripleo_deploy.py @@ -1382,4 +1382,4 @@ class Deploy(command.Command): finally: # send erase sequence to reset the cmdline if paunch/ansible # mangled some escape sequences - utils.send_cmdline_erase_sequence() + utils.reset_cmdline()