Skip to content

Commit

Permalink
Make small fixes to console_output.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenadia committed May 16, 2018
1 parent 0723912 commit caf601b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions openhtf/util/console_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
"""
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit caf601b

Please sign in to comment.