1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

disable 'dense' callback in py26

This commit is contained in:
Brian Coca 2016-11-18 10:54:44 -05:00 committed by Brian Coca
parent 937d872f4b
commit aff5d9160a

View file

@ -21,7 +21,13 @@ __metaclass__ = type
from ansible.plugins.callback.default import CallbackModule as CallbackModule_default
from ansible.utils.color import colorize, hostcolor
from collections import OrderedDict
HAS_OD = False
try:
from collections import OrderedDict
HAS_OD = True
except ImportError:
pass
try:
from __main__ import display
@ -153,6 +159,9 @@ class CallbackModule_dense(CallbackModule_default):
# From CallbackModule
self._display = display
if HAS_OD:
self.disabled = False
self.super_ref = super(CallbackModule, self)
self.super_ref.__init__()
@ -179,6 +188,9 @@ class CallbackModule_dense(CallbackModule_default):
# Start immediately on the first line
sys.stdout.write(vt100.reset + vt100.save + vt100.clearline)
sys.stdout.flush()
else:
display.warning("The 'dense' callback plugin requires OrderedDict which is not available in this version of python, disabling.")
self.disabled = True
def __del__(self):
sys.stdout.write(vt100.restore + vt100.reset + '\n' + vt100.save + vt100.clearline)
@ -478,7 +490,7 @@ class CallbackModule_dense(CallbackModule_default):
)
# When using -vv or higher, simply do the default action
if display.verbosity >= 2:
if display.verbosity >= 2 or not HAS_OD:
CallbackModule = CallbackModule_default
else:
CallbackModule = CallbackModule_dense