mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 21:31:26 -07:00
get_docstring has changed output, rework code to get exception raised by get_docstring
This commit is contained in:
parent
4d24f3ba61
commit
cbe7052ebe
1 changed files with 14 additions and 9 deletions
|
@ -8,6 +8,7 @@ import abc
|
|||
import ast
|
||||
import sys
|
||||
import argparse
|
||||
import traceback
|
||||
|
||||
from fnmatch import fnmatch
|
||||
from utils import find_globals
|
||||
|
@ -16,9 +17,7 @@ from ansible.executor.module_common import REPLACER_WINDOWS
|
|||
from ansible.utils.module_docs import get_docstring, BLACKLIST_MODULES
|
||||
from ansible.module_utils import basic as module_utils_basic
|
||||
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
# We only use StringIO, since we cannot setattr on cStringIO
|
||||
from StringIO import StringIO
|
||||
|
||||
|
||||
|
@ -68,7 +67,6 @@ class Validator(object):
|
|||
ret = []
|
||||
|
||||
for trace in self.traces:
|
||||
#print(trace.replace(self._root, '').lstrip('/'))
|
||||
print(trace)
|
||||
for error in self.errors:
|
||||
print('ERROR: %s' % error)
|
||||
|
@ -326,8 +324,15 @@ class ModuleValidator(Validator):
|
|||
sys_stdout = sys.stdout
|
||||
sys_stderr = sys.stderr
|
||||
sys.stdout = sys.stderr = StringIO()
|
||||
setattr(sys.stdout, 'encoding', sys_stdout.encoding)
|
||||
setattr(sys.stderr, 'encoding', sys_stderr.encoding)
|
||||
try:
|
||||
doc, examples, ret = get_docstring(self.path, verbose=True)
|
||||
trace = None
|
||||
except:
|
||||
doc, examples, ret = get_docstring(self.path)
|
||||
trace = sys.stdout.getvalue()
|
||||
trace = traceback.format_exc()
|
||||
finally:
|
||||
sys.stdout = sys_stdout
|
||||
sys.stderr = sys_stderr
|
||||
if trace:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue