From caf601beead9c2d76caa5fe02871a1de99b76c61 Mon Sep 17 00:00:00 2001 From: Kenneth Schiller Date: Wed, 16 May 2018 16:02:44 -0700 Subject: [PATCH] Make small fixes to console_output.py --- openhtf/util/console_output.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/openhtf/util/console_output.py b/openhtf/util/console_output.py index 445e39191..4a940fccb 100644 --- a/openhtf/util/console_output.py +++ b/openhtf/util/console_output.py @@ -15,7 +15,7 @@ """Console output utilities for OpenHTF. -This module provides a few conviences to help formatting output for the CLI, as +This module provides a few conveniences to help format output for the CLI, as well as for forking output to both a logger (for use with test record loggers) and to the CLI directly (through sys.stdout). """ @@ -50,12 +50,11 @@ Suppress all CLI output from OpenHTF's printing functions and logging. This flag will override any verbosity levels set with -v.''')) - ANSI_ESC_RE = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]') class ActionFailedError(Exception): - """Raised (and caught) when an action is marked as failed.""" + """Indicates an action failed. Used internally by action_result_context().""" def _printed_len(some_string): @@ -261,17 +260,21 @@ def action_result_context(action_text, except Exception as err: if not CLI_QUIET: file.write(''.join((action_text, spacing))) - bracket_print(fail_text, width=status_width, color=colorama.Fore.RED) + bracket_print(fail_text, width=status_width, color=colorama.Fore.RED, + file=file) logger.debug('Result - %s [ %s ]', action_text, fail_text) if not isinstance(err, ActionFailedError): raise + return if not CLI_QUIET: file.write(''.join((action_text, spacing))) if result.success: - bracket_print(succeed_text, width=status_width, color=colorama.Fore.GREEN) + bracket_print(succeed_text, width=status_width, color=colorama.Fore.GREEN, + file=file) logger.debug('Result - %s [ %s ]', action_text, succeed_text) elif result.success is None: - bracket_print(unknown_text, width=status_width, color=colorama.Fore.YELLOW) + bracket_print(unknown_text, width=status_width, color=colorama.Fore.YELLOW, + file=file) logger.debug('Result - %s [ %s ]', action_text, unknown_text)