1
0
Fork 0
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:
Matt Clay 2016-06-24 14:22:27 -07:00 committed by GitHub
parent 04fca42b62
commit c2a5cb6174

View file

@ -21,7 +21,6 @@ __metaclass__ = type
import os
import time
from collections import OrderedDict
from ansible.plugins.callback import CallbackBase
from ansible.utils.unicode import to_bytes
@ -31,6 +30,15 @@ try:
except ImportError:
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):
"""
@ -64,7 +72,7 @@ class CallbackModule(CallbackBase):
self._playbook_path = None
self._playbook_name = None
self._play_name = None
self._task_data = OrderedDict()
self._task_data = None
self.disabled = False
@ -73,6 +81,13 @@ class CallbackModule(CallbackBase):
self._display.warning('The `junit_xml` python module is not installed. '
'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):
os.mkdir(self._output_dir)