diff --git a/devops/helpers/exec_result.py b/devops/helpers/exec_result.py index 8e39e1a0..462d48bb 100644 --- a/devops/helpers/exec_result.py +++ b/devops/helpers/exec_result.py @@ -309,7 +309,7 @@ class ExecResult(object): def __repr__(self): return ( - '{cls}(cmd={cmd}, stdout={stdout}, stderr={stderr}, ' + '{cls}(cmd={cmd!r}, stdout={stdout}, stderr={stderr}, ' 'exit_code={exit_code!s})'.format( cls=self.__class__.__name__, cmd=self.cmd, @@ -320,7 +320,7 @@ class ExecResult(object): def __str__(self): return ( - "{cls}(\n\tcmd={cmd}," + "{cls}(\n\tcmd={cmd!r}," "\n\t stdout=\n'{stdout_brief}'," "\n\tstderr=\n'{stderr_brief}', " '\n\texit_code={exit_code!s}\n)'.format( diff --git a/devops/helpers/ssh_client.py b/devops/helpers/ssh_client.py index 389b4955..e4059f73 100644 --- a/devops/helpers/ssh_client.py +++ b/devops/helpers/ssh_client.py @@ -615,7 +615,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)): ret = self.execute(command, verbose, timeout, **kwargs) if ret['exit_code'] not in expected: message = ( - "{append}Command '{cmd}' returned exit code {code!s} while " + "{append}Command '{cmd!r}' returned exit code {code!s} while " "expected {expected!s}\n" "\tSTDOUT:\n" "{stdout}" @@ -657,7 +657,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)): error_info=error_info, raise_on_err=raise_on_err, **kwargs) if ret['stderr']: message = ( - "{append}Command '{cmd}' STDERR while not expected\n" + "{append}Command '{cmd!r}' STDERR while not expected\n" "\texit code: {code!s}\n" "\tSTDOUT:\n" "{stdout}" @@ -730,7 +730,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)): channel.close() status_tmpl = ( - 'Wait for {0} during {1}s: no return code!\n' + 'Wait for {0!r} during {1}s: no return code!\n' '\tSTDOUT:\n' '{2}\n' '\tSTDERR"\n' @@ -764,7 +764,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)): if verbose: logger.info( - '{cmd} execution results:\n' + '{cmd!r} execution results:\n' 'Exit code: {code!s}\n' 'STDOUT:\n' '{stdout}\n' @@ -777,7 +777,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)): )) else: logger.debug( - '{cmd} execution results: Exit code: {code}'.format( + '{cmd!r} execution results: Exit code: {code}'.format( cmd=command, code=result.exit_code ) @@ -792,7 +792,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)): :type timeout: int :rtype: tuple """ - logger.debug("Executing command: '{}'".format(command.rstrip())) + logger.debug("Executing command: {!r}".format(command.rstrip())) chan = self._ssh.get_transport().open_session(timeout=timeout) diff --git a/devops/helpers/subprocess_runner.py b/devops/helpers/subprocess_runner.py index ef2f4faa..bc53768f 100644 --- a/devops/helpers/subprocess_runner.py +++ b/devops/helpers/subprocess_runner.py @@ -135,11 +135,11 @@ class Subprocess(with_metaclass(SingletonMeta, object)): except OSError: # Nothing to kill logger.warning( - "{} has been completed just after timeout: " + "{!r} has been completed just after timeout: " "please validate timeout.".format(command)) status_tmpl = ( - 'Wait for {0} during {1}s: no return code!\n' + 'Wait for {0!r} during {1}s: no return code!\n' '\tSTDOUT:\n' '{2}\n' '\tSTDERR"\n' @@ -170,12 +170,12 @@ class Subprocess(with_metaclass(SingletonMeta, object)): :rtype: ExecResult :raises: TimeoutError """ - logger.debug("Executing command: '{}'".format(command.rstrip())) + logger.debug("Executing command: {!r}".format(command.rstrip())) result = cls.__exec_command(command=command, timeout=timeout, verbose=verbose, **kwargs) if verbose: logger.debug( - '{cmd} execution results:\n' + '{cmd!r} execution results:\n' 'Exit code: {code!s}\n' 'STDOUT:\n' '{stdout}\n' @@ -188,7 +188,7 @@ class Subprocess(with_metaclass(SingletonMeta, object)): )) else: logger.debug( - '{cmd} execution results: Exit code: {code}'.format( + '{cmd!r} execution results: Exit code: {code}'.format( cmd=command, code=result.exit_code ) @@ -230,7 +230,7 @@ class Subprocess(with_metaclass(SingletonMeta, object)): ret = cls.execute(command, verbose, timeout, **kwargs) if ret['exit_code'] not in expected: message = ( - "{append}Command '{cmd}' returned exit code {code!s} while " + "{append}Command '{cmd!r}' returned exit code {code!s} while " "expected {expected!s}\n" "\tSTDOUT:\n" "{stdout}" @@ -275,7 +275,7 @@ class Subprocess(with_metaclass(SingletonMeta, object)): error_info=error_info, raise_on_err=raise_on_err, **kwargs) if ret['stderr']: message = ( - "{append}Command '{cmd}' STDERR while not expected\n" + "{append}Command '{cmd!r}' STDERR while not expected\n" "\texit code: {code!s}\n" "\tSTDOUT:\n" "{stdout}" diff --git a/devops/tests/helpers/test_exec_result.py b/devops/tests/helpers/test_exec_result.py index 2aecb25e..5964761b 100644 --- a/devops/tests/helpers/test_exec_result.py +++ b/devops/tests/helpers/test_exec_result.py @@ -53,7 +53,7 @@ class TestExecResult(TestCase): self.assertEqual(exec_result.exit_code, exec_result['exit_code']) self.assertEqual( repr(exec_result), - '{cls}(cmd={cmd}, stdout={stdout}, stderr={stderr}, ' + '{cls}(cmd={cmd!r}, stdout={stdout}, stderr={stderr}, ' 'exit_code={exit_code!s})'.format( cls=ExecResult.__name__, cmd=cmd, @@ -64,7 +64,7 @@ class TestExecResult(TestCase): ) self.assertEqual( str(exec_result), - "{cls}(\n\tcmd={cmd}," + "{cls}(\n\tcmd={cmd!r}," "\n\t stdout=\n'{stdout_brief}'," "\n\tstderr=\n'{stderr_brief}', " '\n\texit_code={exit_code!s}\n)'.format( diff --git a/devops/tests/helpers/test_ssh_client.py b/devops/tests/helpers/test_ssh_client.py index 38fb724c..e2fa451c 100644 --- a/devops/tests/helpers/test_ssh_client.py +++ b/devops/tests/helpers/test_ssh_client.py @@ -936,7 +936,7 @@ class TestExecute(TestCase): )) self.assertIn( mock.call.debug( - "Executing command: '{}'".format(command.rstrip())), + "Executing command: {!r}".format(command.rstrip())), logger.mock_calls ) @@ -971,7 +971,7 @@ class TestExecute(TestCase): )) self.assertIn( mock.call.debug( - "Executing command: '{}'".format(command.rstrip())), + "Executing command: {!r}".format(command.rstrip())), logger.mock_calls ) @@ -1004,7 +1004,7 @@ class TestExecute(TestCase): )) self.assertIn( mock.call.debug( - "Executing command: '{}'".format(command.rstrip())), + "Executing command: {!r}".format(command.rstrip())), logger.mock_calls ) @@ -1040,7 +1040,7 @@ class TestExecute(TestCase): )) self.assertIn( mock.call.debug( - "Executing command: '{}'".format(command.rstrip())), + "Executing command: {!r}".format(command.rstrip())), logger.mock_calls ) @@ -1072,7 +1072,7 @@ class TestExecute(TestCase): )) self.assertIn( mock.call.debug( - "Executing command: '{}'".format(command.rstrip())), + "Executing command: {!r}".format(command.rstrip())), logger.mock_calls ) @@ -1104,7 +1104,7 @@ class TestExecute(TestCase): )) self.assertIn( mock.call.debug( - "Executing command: '{}'".format(command.rstrip())), + "Executing command: {!r}".format(command.rstrip())), logger.mock_calls ) @@ -1149,7 +1149,7 @@ class TestExecute(TestCase): )) self.assertIn( mock.call.debug( - "Executing command: '{}'".format(command.rstrip())), + "Executing command: {!r}".format(command.rstrip())), logger.mock_calls ) @@ -1218,7 +1218,7 @@ class TestExecute(TestCase): mock.call.close())) logger.assert_has_calls(( mock.call.info( - '{cmd} execution results:\n' + '{cmd!r} execution results:\n' 'Exit code: {code!s}\n' 'STDOUT:\n' '{stdout}\n' @@ -1271,7 +1271,7 @@ class TestExecute(TestCase): mock.call.close())) logger.assert_has_calls(( mock.call.info( - '{cmd} execution results:\n' + '{cmd!r} execution results:\n' 'Exit code: {code!s}\n' 'STDOUT:\n' '{stdout}\n' diff --git a/devops/tests/helpers/test_subprocess_runner.py b/devops/tests/helpers/test_subprocess_runner.py index db4388f1..7f271e07 100644 --- a/devops/tests/helpers/test_subprocess_runner.py +++ b/devops/tests/helpers/test_subprocess_runner.py @@ -95,9 +95,9 @@ class TestSubprocessRunner(TestCase): stdin=PIPE, stdout=PIPE, universal_newlines=False), )) logger.assert_has_calls(( - call.debug("Executing command: '{}'".format(command.rstrip())), + call.debug("Executing command: {!r}".format(command.rstrip())), call.debug( - '{cmd} execution results: Exit code: {code}'.format( + '{cmd!r} execution results: Exit code: {code}'.format( cmd=command, code=result.exit_code )), @@ -115,9 +115,9 @@ class TestSubprocessRunner(TestCase): result = runner.execute(command, verbose=True) logger.assert_has_calls(( - call.debug("Executing command: '{}'".format(command.rstrip())), + call.debug("Executing command: {!r}".format(command.rstrip())), call.debug( - '{cmd} execution results:\n' + '{cmd!r} execution results:\n' 'Exit code: {code!s}\n' 'STDOUT:\n' '{stdout}\n'