mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #42094 from terminalmage/quiet-exception
Prevent command from showing in exception when output_loglevel=quiet
This commit is contained in:
commit
687992c240
1 changed files with 17 additions and 2 deletions
|
@ -526,10 +526,25 @@ def _run(cmd,
|
|||
try:
|
||||
proc = salt.utils.timed_subprocess.TimedProc(cmd, **kwargs)
|
||||
except (OSError, IOError) as exc:
|
||||
raise CommandExecutionError(
|
||||
msg = (
|
||||
'Unable to run command \'{0}\' with the context \'{1}\', '
|
||||
'reason: {2}'.format(cmd, kwargs, exc)
|
||||
'reason: '.format(
|
||||
cmd if _check_loglevel(output_loglevel) is not None
|
||||
else 'REDACTED',
|
||||
kwargs
|
||||
)
|
||||
)
|
||||
try:
|
||||
if exc.filename is None:
|
||||
msg += 'command not found'
|
||||
else:
|
||||
msg += '{0}: {1}'.format(exc, exc.filename)
|
||||
except AttributeError:
|
||||
# Both IOError and OSError have the filename attribute, so this
|
||||
# is a precaution in case the exception classes in the previous
|
||||
# try/except are changed.
|
||||
msg += 'unknown'
|
||||
raise CommandExecutionError(msg)
|
||||
|
||||
try:
|
||||
proc.run()
|
||||
|
|
Loading…
Add table
Reference in a new issue