mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
adding display to plugins and start moving debug to display
This commit is contained in:
parent
5d51f3abda
commit
851ed45bbf
20 changed files with 152 additions and 109 deletions
|
@ -19,11 +19,18 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
||||
__all__ = ['LookupBase']
|
||||
|
||||
class LookupBase:
|
||||
def __init__(self, loader=None, **kwargs):
|
||||
self._loader = loader
|
||||
self._display = display
|
||||
|
||||
def _flatten(self, terms):
|
||||
ret = []
|
||||
|
|
|
@ -38,6 +38,7 @@ class LookupModule(LookupBase):
|
|||
basedir = self._loader.get_basedir()
|
||||
|
||||
for term in terms:
|
||||
self._display.debug("File lookup term: %s" % term)
|
||||
|
||||
# Special handling of the file lookup, used primarily when the
|
||||
# lookup is done from a role. If the file isn't found in the
|
||||
|
@ -46,6 +47,7 @@ class LookupModule(LookupBase):
|
|||
# itself (which will be relative to the current working dir)
|
||||
|
||||
lookupfile = self._loader.path_dwim_relative(basedir, 'files', term)
|
||||
self._display.vvvv("File lookup using %s as file" % lookupfile)
|
||||
try:
|
||||
if lookupfile:
|
||||
contents, show_data = self._loader._get_file_contents(lookupfile)
|
||||
|
|
|
@ -40,8 +40,10 @@ class LookupModule(LookupBase):
|
|||
basedir = self._loader.get_basedir()
|
||||
|
||||
for term in terms:
|
||||
self._display.debug("File lookup term: %s" % term)
|
||||
|
||||
lookupfile = self._loader.path_dwim_relative(basedir, 'templates', term)
|
||||
self._display.vvvv("File lookup using %s as file" % lookupfile)
|
||||
if lookupfile and os.path.exists(lookupfile):
|
||||
with open(lookupfile, 'r') as f:
|
||||
template_data = f.read()
|
||||
|
|
|
@ -36,6 +36,7 @@ class LookupModule(LookupBase):
|
|||
|
||||
ret = []
|
||||
for term in terms:
|
||||
self._display.vvvv("url lookup connecting to %s" % term)
|
||||
try:
|
||||
response = open_url(term, validate_certs=validate_certs)
|
||||
except urllib2.URLError as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue