Minor change to SSH/Subprocess commands logging

Change-Id: If27e761130d8bc469c9b1fd2bb6b80ebedf85669
This commit is contained in:
Dennis Dmitriev 2017-08-30 13:08:11 +03:00
parent c64ea944d9
commit 9998c3b49a
3 changed files with 8 additions and 11 deletions

View File

@ -14,9 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
CMD_EXEC = u"\nExecuting command: '{cmd!s}'"
CMD_RESULT = (u"\nCommand '{cmd!s}'\nexecution results: "
u"Exit code: '{code!s}'")
CMD_EXEC = u"Executing command:\n{cmd!s}\n"
CMD_RESULT = (u"Command exit code '{code!s}':\n{cmd!s}\n")
CMD_UNEXPECTED_EXIT_CODE = (u"{append}Command '{cmd!s}' returned "
u"exit code '{code!s}' while "
u"expected '{expected!s}'\n")

View File

@ -65,7 +65,7 @@ username = 'user'
password = 'pass'
private_keys = []
command = 'ls ~\nline 2\nline 3\nline с кирилицей'
command_log = u"\nExecuting command: '{!s}'".format(command.rstrip())
command_log = u"Executing command:\n{!s}\n".format(command.rstrip())
stdout_list = [b' \n', b'2\n', b'3\n', b' \n']
stderr_list = [b' \n', b'0\n', b'1\n', b' \n']
encoded_cmd = base64.b64encode(
@ -925,9 +925,8 @@ class TestExecute(unittest.TestCase):
@staticmethod
def gen_cmd_result_log_message(result):
return (u"\nCommand '{cmd!s}'\nexecution results: "
u"Exit code: '{code!s}'".format(
cmd=result.cmd.rstrip(), code=result.exit_code))
return (u"Command exit code '{code!s}':\n{cmd!s}\n"
.format(cmd=result.cmd.rstrip(), code=result.exit_code))
def test_execute_async(self, client, policy, logger):
chan = mock.Mock()

View File

@ -26,7 +26,7 @@ from devops.helpers import exec_result
from devops.helpers import subprocess_runner
command = 'ls ~\nline 2\nline 3\nline с кирилицей'
command_log = u"\nExecuting command: '{!s}'".format(command.rstrip())
command_log = u"Executing command:\n{!s}\n".format(command.rstrip())
stdout_list = [b' \n', b'2\n', b'3\n', b' \n']
stderr_list = [b' \n', b'0\n', b'1\n', b' \n']
@ -78,9 +78,8 @@ class TestSubprocessRunner(unittest.TestCase):
@staticmethod
def gen_cmd_result_log_message(result):
return (u"\nCommand '{cmd!s}'\nexecution results: "
u"Exit code: '{code!s}'".format(
cmd=result.cmd.rstrip(), code=result.exit_code))
return (u"Command exit code '{code!s}':\n{cmd!s}\n"
.format(cmd=result.cmd.rstrip(), code=result.exit_code))
def test_call(self, popen, fcntl, select, logger):
popen_obj, exp_result = self.prepare_close(popen)