mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
parent
d5ad3093d6
commit
51b595992b
11 changed files with 75 additions and 78 deletions
|
@ -18,24 +18,25 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import errno
|
||||
import fcntl
|
||||
import textwrap
|
||||
import getpass
|
||||
import locale
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import time
|
||||
import locale
|
||||
import logging
|
||||
import getpass
|
||||
import errno
|
||||
|
||||
from struct import unpack, pack
|
||||
from termios import TIOCGWINSZ
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.utils.color import stringc
|
||||
from ansible.module_utils._text import to_bytes, to_text
|
||||
from ansible.utils.color import stringc
|
||||
|
||||
|
||||
try:
|
||||
|
@ -47,7 +48,7 @@ except NameError:
|
|||
|
||||
|
||||
logger = None
|
||||
#TODO: make this a logging callback instead
|
||||
# TODO: make this a logging callback instead
|
||||
if C.DEFAULT_LOG_PATH:
|
||||
path = C.DEFAULT_LOG_PATH
|
||||
if (os.path.exists(path) and os.access(path, os.W_OK)) or os.access(os.path.dirname(path), os.W_OK):
|
||||
|
@ -58,11 +59,14 @@ if C.DEFAULT_LOG_PATH:
|
|||
else:
|
||||
print("[WARNING]: log file at %s is not writeable and we cannot create it, aborting\n" % path, file=sys.stderr)
|
||||
|
||||
b_COW_PATHS = (b"/usr/bin/cowsay",
|
||||
b"/usr/games/cowsay",
|
||||
b"/usr/local/bin/cowsay", # BSD path for cowsay
|
||||
b"/opt/local/bin/cowsay", # MacPorts path for cowsay
|
||||
)
|
||||
b_COW_PATHS = (
|
||||
b"/usr/bin/cowsay",
|
||||
b"/usr/games/cowsay",
|
||||
b"/usr/local/bin/cowsay", # BSD path for cowsay
|
||||
b"/opt/local/bin/cowsay", # MacPorts path for cowsay
|
||||
)
|
||||
|
||||
|
||||
class Display:
|
||||
|
||||
def __init__(self, verbosity=0):
|
||||
|
@ -72,8 +76,8 @@ class Display:
|
|||
|
||||
# list of all deprecation messages to prevent duplicate display
|
||||
self._deprecations = {}
|
||||
self._warns = {}
|
||||
self._errors = {}
|
||||
self._warns = {}
|
||||
self._errors = {}
|
||||
|
||||
self.b_cowsay = None
|
||||
self.noncow = C.ANSIBLE_COW_SELECTION
|
||||
|
@ -84,7 +88,7 @@ class Display:
|
|||
try:
|
||||
cmd = subprocess.Popen([self.b_cowsay, "-l"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(out, err) = cmd.communicate()
|
||||
self.cows_available = set([ to_text(c) for c in out.split() ])
|
||||
self.cows_available = set([to_text(c) for c in out.split()])
|
||||
if C.ANSIBLE_COW_WHITELIST:
|
||||
self.cows_available = set(C.ANSIBLE_COW_WHITELIST).intersection(self.cows_available)
|
||||
except:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue