From 906826d752eec11ec1913982256a9875e093e352 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sun, 10 Nov 2019 20:21:15 -0700 Subject: [PATCH] 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 --- scripts/wk/std.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/wk/std.py b/scripts/wk/std.py index 2428b168..a9b5d54a 100644 --- a/scripts/wk/std.py +++ b/scripts/wk/std.py @@ -430,7 +430,10 @@ class TryAndPrint(): stdout = stdout.decode('utf8') output = stdout.strip().splitlines() else: - output = list(output) + try: + output = list(output) + except TypeError: + output = [output] # Safety check if not output: @@ -524,7 +527,7 @@ class TryAndPrint(): # Run function and catch exceptions 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: output = function(*args, **kwargs) except w_exceptions as _exception: @@ -554,7 +557,8 @@ class TryAndPrint(): result_msg = self._format_function_output(output) print(result_msg) 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 self._log_result(message, result_msg)