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