mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix junit callback plugin for Python 2.6. (#16440)
This commit is contained in:
parent
04fca42b62
commit
c2a5cb6174
1 changed files with 17 additions and 2 deletions
|
@ -21,7 +21,6 @@ __metaclass__ = type
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
from ansible.plugins.callback import CallbackBase
|
from ansible.plugins.callback import CallbackBase
|
||||||
from ansible.utils.unicode import to_bytes
|
from ansible.utils.unicode import to_bytes
|
||||||
|
|
||||||
|
@ -31,6 +30,15 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_JUNIT_XML = False
|
HAS_JUNIT_XML = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
from collections import OrderedDict
|
||||||
|
HAS_ORDERED_DICT = True
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
from ordereddict import OrderedDict
|
||||||
|
HAS_ORDERED_DICT = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_ORDERED_DICT = False
|
||||||
|
|
||||||
class CallbackModule(CallbackBase):
|
class CallbackModule(CallbackBase):
|
||||||
"""
|
"""
|
||||||
|
@ -64,7 +72,7 @@ class CallbackModule(CallbackBase):
|
||||||
self._playbook_path = None
|
self._playbook_path = None
|
||||||
self._playbook_name = None
|
self._playbook_name = None
|
||||||
self._play_name = None
|
self._play_name = None
|
||||||
self._task_data = OrderedDict()
|
self._task_data = None
|
||||||
|
|
||||||
self.disabled = False
|
self.disabled = False
|
||||||
|
|
||||||
|
@ -73,6 +81,13 @@ class CallbackModule(CallbackBase):
|
||||||
self._display.warning('The `junit_xml` python module is not installed. '
|
self._display.warning('The `junit_xml` python module is not installed. '
|
||||||
'Disabling the `junit` callback plugin.')
|
'Disabling the `junit` callback plugin.')
|
||||||
|
|
||||||
|
if HAS_ORDERED_DICT:
|
||||||
|
self._task_data = OrderedDict()
|
||||||
|
else:
|
||||||
|
self.disabled = True
|
||||||
|
self._display.warning('The `ordereddict` python module is not installed. '
|
||||||
|
'Disabling the `junit` callback plugin.')
|
||||||
|
|
||||||
if not os.path.exists(self._output_dir):
|
if not os.path.exists(self._output_dir):
|
||||||
os.mkdir(self._output_dir)
|
os.mkdir(self._output_dir)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue