Updated TryAndPrint()
* Don't log function name unless in debug mode * Log msg_good instead of UNKNOWN for non-failed functions with no output * Avoid issue if function returns int
This commit is contained in:
parent
196e2adc82
commit
906826d752
1 changed files with 7 additions and 3 deletions
|
|
@ -430,7 +430,10 @@ class TryAndPrint():
|
||||||
stdout = stdout.decode('utf8')
|
stdout = stdout.decode('utf8')
|
||||||
output = stdout.strip().splitlines()
|
output = stdout.strip().splitlines()
|
||||||
else:
|
else:
|
||||||
output = list(output)
|
try:
|
||||||
|
output = list(output)
|
||||||
|
except TypeError:
|
||||||
|
output = [output]
|
||||||
|
|
||||||
# Safety check
|
# Safety check
|
||||||
if not output:
|
if not output:
|
||||||
|
|
@ -524,7 +527,7 @@ class TryAndPrint():
|
||||||
|
|
||||||
# Run function and catch exceptions
|
# Run function and catch exceptions
|
||||||
print(f'{" "*self.indent}{message:<{self.width}}', end='', flush=True)
|
print(f'{" "*self.indent}{message:<{self.width}}', end='', flush=True)
|
||||||
LOG.info('Running function: %s.%s', function.__module__, function.__name__)
|
LOG.debug('Running function: %s.%s', function.__module__, function.__name__)
|
||||||
try:
|
try:
|
||||||
output = function(*args, **kwargs)
|
output = function(*args, **kwargs)
|
||||||
except w_exceptions as _exception:
|
except w_exceptions as _exception:
|
||||||
|
|
@ -554,7 +557,8 @@ class TryAndPrint():
|
||||||
result_msg = self._format_function_output(output)
|
result_msg = self._format_function_output(output)
|
||||||
print(result_msg)
|
print(result_msg)
|
||||||
else:
|
else:
|
||||||
print_success(msg_good if msg_good else self.msg_good, log=False)
|
result_msg = msg_good if msg_good else self.msg_good
|
||||||
|
print_success(result_msg, log=False)
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
self._log_result(message, result_msg)
|
self._log_result(message, result_msg)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue