use toggle

most of our tests dump output w/o tty to check aginast expected
  formatted output, this will ensure backwards compat
pull/73834/head
Brian Coca 3 years ago
parent 6d1e22fb85
commit e095235e37

@ -1688,6 +1688,16 @@ NETWORK_GROUP_MODULES:
- {key: network_group_modules, section: defaults}
type: list
yaml: {key: defaults.network_group_modules}
NOTTY_WRAP:
name: no tty wrap
description: Toggle wrapping text in the abcense of a TTY
default: True
type: bool
version_added: '2.13'
env:
- name: ANSIBLE_NOTTY_WRAP
ini:
- {key: notty_wrap, section: defaults}
INJECT_FACTS_AS_VARS:
default: True
description:

@ -46,13 +46,6 @@ import typing as t
from functools import wraps
from struct import unpack, pack
# wrap becomes noop if not using tty
if sys.__stdin__.isatty():
from textwrap import wrap
else:
def wrap(text, width, **kwargs):
return text
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleAssertionError, AnsiblePromptInterrupt, AnsiblePromptNoninteractive
from ansible.module_utils.common.text.converters import to_bytes, to_text
@ -68,6 +61,13 @@ if t.TYPE_CHECKING:
P = t.ParamSpec('P')
# wrap becomes noop if not using tty
if if C.NOTTY_WRAP or sys.__stdin__.isatty():
from textwrap import wrap
else:
def wrap(text, width, **kwargs):
return text
_LIBC = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
# Set argtypes, to avoid segfault if the wrong type is provided,
# restype is assumed to be c_int

Loading…
Cancel
Save