Run cleanup commands in quiet mode for DEBUG, TRACE.
This commit is contained in:
parent
e0a4fc4ea7
commit
cb38354df3
2 changed files with 9 additions and 4 deletions
|
@ -391,7 +391,12 @@ class Config(object):
|
|||
cmd = cleanup_cmd.split()
|
||||
cmd.append(self.local.target_host[0])
|
||||
try:
|
||||
self.local.run(cmd, return_output=False, save_output=False)
|
||||
if self.log.getEffectiveLevel() <= logging.DEBUG:
|
||||
quiet_mode = False
|
||||
else:
|
||||
quiet_mode = True
|
||||
self.local.run(cmd, return_output=False, save_output=False,
|
||||
quiet_mode=quiet_mode)
|
||||
except cdist.Error as e:
|
||||
# Log warning but continue.
|
||||
self.log.warning("Cleanup command failed: %s", e)
|
||||
|
|
|
@ -201,7 +201,7 @@ class Local(object):
|
|||
os.makedirs(path, exist_ok=True)
|
||||
|
||||
def run(self, command, env=None, return_output=False, message_prefix=None,
|
||||
save_output=True):
|
||||
save_output=True, quiet_mode=False):
|
||||
"""Run the given command with the given environment.
|
||||
Return the output as a string.
|
||||
|
||||
|
@ -226,7 +226,7 @@ class Local(object):
|
|||
|
||||
self.log.trace("Local run: %s", command)
|
||||
try:
|
||||
if self.quiet_mode:
|
||||
if self.quiet_mode or quiet_mode:
|
||||
stderr = subprocess.DEVNULL
|
||||
else:
|
||||
stderr = None
|
||||
|
@ -242,7 +242,7 @@ class Local(object):
|
|||
# In some cases no output is saved.
|
||||
# This is used for shell command, stdout and stderr
|
||||
# must not be catched.
|
||||
if self.quiet_mode:
|
||||
if self.quiet_mode or quiet_mode:
|
||||
stdout = subprocess.DEVNULL
|
||||
else:
|
||||
stdout = None
|
||||
|
|
Loading…
Reference in a new issue