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.plugins.callback.default import CallbackModule as CallbackModule_default
from ansible.utils.color import colorize, hostcolor 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: try:
from __main__ import display from __main__ import display
@ -153,32 +159,38 @@ class CallbackModule_dense(CallbackModule_default):
# From CallbackModule # From CallbackModule
self._display = display self._display = display
self.super_ref = super(CallbackModule, self) if HAS_OD:
self.super_ref.__init__()
# Attributes to remove from results for more density self.disabled = False
self.removed_attributes = ( self.super_ref = super(CallbackModule, self)
# 'changed', self.super_ref.__init__()
'delta',
# 'diff',
'end',
'failed',
'failed_when_result',
'invocation',
'start',
'stdout_lines',
)
# Initiate data structures # Attributes to remove from results for more density
self.hosts = OrderedDict() self.removed_attributes = (
self.keep = False # 'changed',
self.shown_title = False 'delta',
self.count = dict(play=0, handler=0, task=0) # 'diff',
self.type = 'foo' 'end',
'failed',
'failed_when_result',
'invocation',
'start',
'stdout_lines',
)
# Start immediately on the first line # Initiate data structures
sys.stdout.write(vt100.reset + vt100.save + vt100.clearline) self.hosts = OrderedDict()
sys.stdout.flush() self.keep = False
self.shown_title = False
self.count = dict(play=0, handler=0, task=0)
self.type = 'foo'
# 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): def __del__(self):
sys.stdout.write(vt100.restore + vt100.reset + '\n' + vt100.save + vt100.clearline) 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 # 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 CallbackModule = CallbackModule_default
else: else:
CallbackModule = CallbackModule_dense CallbackModule = CallbackModule_dense