From ea58cbd1716b815b9557f48a5d0ae8a7097fd5fd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 20 Sep 2017 21:19:19 +0200 Subject: [PATCH] Better format command error output. --- cdist/exec/util.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cdist/exec/util.py b/cdist/exec/util.py index b71b9bcc..16b685cf 100644 --- a/cdist/exec/util.py +++ b/cdist/exec/util.py @@ -133,10 +133,16 @@ def handle_called_process_error(err, command): # "stdout: {}\n" # "stderr: {}").format( # err.returncode, err.output, errout)) - raise cdist.Error("Command failed: " + " ".join(command) + - (" with returncode: {}\n" - "stdout: {}").format( - err.returncode, err.output)) + if err.output: + output = err.output + '\n' + else: + output = '' + raise cdist.Error(("Command failed: '{}'\n" + "return code: {}\n" + "---- BEGIN stdout ----\n" + "{}" + "---- END stdout ----").format( + " ".join(command), err.returncode, output)) def _call_get_stdout(command, env=None, stderr=None):