<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def action_result_context(action_text, width=60, status_width=8, succeed_text='OK', fail_text='FAIL', unknown_text='????', file=sys.stdout, logger=_LOG):
 """A contextmanager that prints actions and results to the CLI. When entering the context, the action will be printed, and when the context is exited, the result will be printed. The object yielded by the context is used to mark the action as a success or failure, and a raise from inside the context will also result in the action being marked fail. If the result is left unset, then indicative text ("????") will be printed as the result. Args: action_text: Text to be displayed that describes the action being taken. width: Total width for each line of output. status_width: Width of the just the status message portion of each line. succeed_text: Status message displayed when the action succeeds. fail_text: Status message displayed when the action fails. unknown_text: Status message displayed when the result is left unset. file: Specific file object to write to write CLI output to. logger: A logger to use, or None to disable logging. Example usage: time.sleep(2) act.succeed() time.sleep(2) time.sleep(2) act.fail() time.sleep(2) import textwrap raise RuntimeError(textwrap.dedent('''\ Uh oh, looks like there was a raise in the mix. If you see this message, it means you are running the console_output module directly rather than using it as a library. Things to try: * Not running it as a module. * Running it as a module and enjoying the preview text. * Getting another coffee.''')) Example output: """

  if logger:
    logger.debug('Action - %s', action_text)
  if not CLI_QUIET:
    file.write(''.join((action_text, '\r')))
    file.flush()
    spacing = (width - status_width - _printed_len(action_text)) * ' '

  result = ActionResult()
  try:
    yield result
  except Exception as err:
    if logger:
      logger.debug('Result - %s [ %s ]', action_text, fail_text)
    if not CLI_QUIET:
      file.write(''.join((action_text, spacing)))
      bracket_print(fail_text, width=status_width, color=colorama.Fore.RED,
                    file=file)
    if not isinstance(err, ActionFailedError):
      raise
    return

  result_text = succeed_text if result.success else unknown_text
  result_color = colorama.Fore.GREEN if result.success else colorama.Fore.YELLOW
  if logger:
    logger.debug('Result - %s [ %s ]', action_text, result_text)
  if not CLI_QUIET:
    file.write(''.join((action_text, spacing)))
    bracket_print(result_text, width=status_width, color=result_color,
                  file=file)