|
|
|
|
@ -40,7 +40,6 @@ import secrets
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
import termios
|
|
|
|
|
import textwrap
|
|
|
|
|
import threading
|
|
|
|
|
import time
|
|
|
|
|
import tty
|
|
|
|
|
@ -329,7 +328,6 @@ class Display(metaclass=Singleton):
|
|
|
|
|
self.noncow = C.ANSIBLE_COW_SELECTION
|
|
|
|
|
|
|
|
|
|
self.set_cowsay_info()
|
|
|
|
|
self._wrap_stderr = C.WRAP_STDERR
|
|
|
|
|
|
|
|
|
|
if self.b_cowsay:
|
|
|
|
|
try:
|
|
|
|
|
@ -663,13 +661,6 @@ class Display(metaclass=Singleton):
|
|
|
|
|
|
|
|
|
|
return _join_sentences(msg, deprecation_msg)
|
|
|
|
|
|
|
|
|
|
def _wrap_message(self, msg: str, wrap_text: bool) -> str:
|
|
|
|
|
if wrap_text and self._wrap_stderr:
|
|
|
|
|
wrapped = textwrap.wrap(msg, self.columns, drop_whitespace=False)
|
|
|
|
|
msg = "\n".join(wrapped) + "\n"
|
|
|
|
|
|
|
|
|
|
return msg
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _deduplicate(msg: str, messages: set[str]) -> bool:
|
|
|
|
|
"""
|
|
|
|
|
@ -786,9 +777,6 @@ class Display(metaclass=Singleton):
|
|
|
|
|
msg = _format_message(warning, _traceback.is_traceback_enabled(_traceback.TracebackEvent.DEPRECATED))
|
|
|
|
|
msg = f'[DEPRECATION WARNING]: {msg}'
|
|
|
|
|
|
|
|
|
|
# DTFIX3: what should we do with wrap_message?
|
|
|
|
|
msg = self._wrap_message(msg=msg, wrap_text=True)
|
|
|
|
|
|
|
|
|
|
if self._deduplicate(msg, self._deprecations):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
@ -805,6 +793,8 @@ class Display(metaclass=Singleton):
|
|
|
|
|
"""Display a warning message."""
|
|
|
|
|
_skip_stackwalk = True
|
|
|
|
|
|
|
|
|
|
# deprecated: description='The formatted argument has no effect.' core_version='2.23'
|
|
|
|
|
|
|
|
|
|
# This is the pre-proxy half of the `warning` implementation.
|
|
|
|
|
# Any logic that must occur on workers needs to be implemented here.
|
|
|
|
|
|
|
|
|
|
@ -824,13 +814,12 @@ class Display(metaclass=Singleton):
|
|
|
|
|
|
|
|
|
|
if warning_ctx := _DeferredWarningContext.current(optional=True):
|
|
|
|
|
warning_ctx.capture(warning)
|
|
|
|
|
# DTFIX3: what to do about propagating wrap_text?
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self._warning(warning, wrap_text=not formatted)
|
|
|
|
|
self._warning(warning)
|
|
|
|
|
|
|
|
|
|
@_proxy
|
|
|
|
|
def _warning(self, warning: _messages.WarningSummary, wrap_text: bool) -> None:
|
|
|
|
|
def _warning(self, warning: _messages.WarningSummary) -> None:
|
|
|
|
|
"""Internal implementation detail, use `warning` instead."""
|
|
|
|
|
|
|
|
|
|
# This is the post-proxy half of the `warning` implementation.
|
|
|
|
|
@ -842,9 +831,6 @@ class Display(metaclass=Singleton):
|
|
|
|
|
if self._deduplicate(msg, self._warns):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# DTFIX3: what should we do with wrap_message?
|
|
|
|
|
msg = self._wrap_message(msg=msg, wrap_text=wrap_text)
|
|
|
|
|
|
|
|
|
|
self.display(msg, color=C.config.get_config_value('COLOR_WARN'), stderr=True, caplevel=-2)
|
|
|
|
|
|
|
|
|
|
@_proxy
|
|
|
|
|
@ -933,19 +919,20 @@ class Display(metaclass=Singleton):
|
|
|
|
|
warning_ctx.capture(warning)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self._warning(warning, wrap_text=False)
|
|
|
|
|
self._warning(warning)
|
|
|
|
|
|
|
|
|
|
def error(self, msg: str | BaseException, wrap_text: bool = True, stderr: bool = True) -> None:
|
|
|
|
|
"""Display an error message."""
|
|
|
|
|
_skip_stackwalk = True
|
|
|
|
|
|
|
|
|
|
# deprecated: description='The wrap_text argument has no effect.' core_version='2.23'
|
|
|
|
|
# deprecated: description='The stderr argument has no effect.' core_version='2.23'
|
|
|
|
|
|
|
|
|
|
# This is the pre-proxy half of the `error` implementation.
|
|
|
|
|
# Any logic that must occur on workers needs to be implemented here.
|
|
|
|
|
|
|
|
|
|
if isinstance(msg, BaseException):
|
|
|
|
|
event = _error_factory.ControllerEventFactory.from_exception(msg, _traceback.is_traceback_enabled(_traceback.TracebackEvent.ERROR))
|
|
|
|
|
|
|
|
|
|
wrap_text = False
|
|
|
|
|
else:
|
|
|
|
|
event = _messages.Event(
|
|
|
|
|
msg=msg,
|
|
|
|
|
@ -956,10 +943,10 @@ class Display(metaclass=Singleton):
|
|
|
|
|
event=event,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self._error(error, wrap_text=wrap_text, stderr=stderr)
|
|
|
|
|
self._error(error, stderr=True)
|
|
|
|
|
|
|
|
|
|
@_proxy
|
|
|
|
|
def _error(self, error: _messages.ErrorSummary, wrap_text: bool, stderr: bool) -> None:
|
|
|
|
|
def _error(self, error: _messages.ErrorSummary, stderr: bool) -> None:
|
|
|
|
|
"""Internal implementation detail, use `error` instead."""
|
|
|
|
|
|
|
|
|
|
# This is the post-proxy half of the `error` implementation.
|
|
|
|
|
@ -971,9 +958,6 @@ class Display(metaclass=Singleton):
|
|
|
|
|
if self._deduplicate(msg, self._errors):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# DTFIX3: what should we do with wrap_message?
|
|
|
|
|
msg = self._wrap_message(msg=msg, wrap_text=wrap_text)
|
|
|
|
|
|
|
|
|
|
self.display(msg, color=C.config.get_config_value('COLOR_ERROR'), stderr=stderr, caplevel=-1)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|