Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: BenjiReis <[email protected]>
  • Loading branch information
benjamreis committed Oct 3, 2023
1 parent dbbe625 commit bce9459
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions SOURCES/etc/xapi.d/plugins/xcpngutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ def __init__(self, code, command, stderr, stdout):
self.stdout = stdout

def __str__(self):
return f"Command {self.command} failed with code: {self.returncode} and stderr: {self.stderr}," + \
f" stdout: {self.stdout}"
return f"Command '{self.command}' failed with code: {self.returncode}"

def run_command(command, check=True):
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down Expand Up @@ -137,7 +136,8 @@ def wrapper(*args, **kwds):
except ProcessException as e:
raise_plugin_error(e.returncode, str(e), backtrace=traceback.format_exc())
except Exception as e:
raise_plugin_error('-1', str(e), backtrace=traceback.format_exc())
raise_plugin_error(
'-1', str(e), detail=f"stdout: '{e.stdout}', stderr: '{e.stderr}'", backtrace=traceback.format_exc())

return wrapper

Expand Down
2 changes: 1 addition & 1 deletion tests/test_raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_raid_error(self, run_command, fs):
assert e.value.params[1] == 'Error!'

def test_raid_missing(self, run_command, fs):
run_command.side_effect = ProcessException(1, MDADM_DETAIL_CMD, "", "")
run_command.side_effect = ProcessException(1, MDADM_DETAIL_CMD, "stderr", "stdout")
res = check_raid_pool(None, None)
assert json.loads(res) == json.loads("{}")
run_command.assert_called_once_with(MDADM_DETAIL_CMD)
Expand Down

0 comments on commit bce9459

Please sign in to comment.