Remove direct calls to print and cleanup imports

All display of information should go through display instead of through print.
pull/9192/merge
Toshio Kuratomi 8 years ago committed by Brian Coca
parent a0f27d552c
commit 6a3893c518

@ -195,8 +195,8 @@ class Base(with_metaclass(BaseMeta, object)):
def dump_me(self, depth=0): def dump_me(self, depth=0):
if depth == 0: if depth == 0:
print("DUMPING OBJECT ------------------------------------------------------") display.debug("DUMPING OBJECT ------------------------------------------------------")
print("%s- %s (%s, id=%s)" % (" " * depth, self.__class__.__name__, self, id(self))) display.debug("%s- %s (%s, id=%s)" % (" " * depth, self.__class__.__name__, self, id(self)))
if hasattr(self, '_parent') and self._parent: if hasattr(self, '_parent') and self._parent:
self._parent.dump_me(depth+2) self._parent.dump_me(depth+2)
dep_chain = self._parent.get_dep_chain() dep_chain = self._parent.get_dep_chain()

@ -19,19 +19,18 @@ __metaclass__ = type
import collections import collections
import os import os
import sys
import time import time
from multiprocessing import Lock from multiprocessing import Lock
from itertools import chain from itertools import chain
from ansible import constants as C from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.plugins.cache.base import BaseCacheModule from ansible.plugins.cache.base import BaseCacheModule
try: try:
import memcache import memcache
except ImportError: except ImportError:
print('python-memcached is required for the memcached fact cache') raise AnsibleError("python-memcached is required for the memcached fact cache")
sys.exit(1)
class ProxyClientPool(object): class ProxyClientPool(object):

@ -16,7 +16,8 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import os,sys,re,socket import os
HAS_XMPP = True HAS_XMPP = True
try: try:
import xmpp import xmpp
@ -24,9 +25,8 @@ except ImportError:
HAS_XMPP = False HAS_XMPP = False
from ansible.plugins.callback import CallbackBase from ansible.plugins.callback import CallbackBase
from ansible import utils
from ansible.module_utils import basic
from ansible.utils.unicode import to_unicode, to_bytes
class CallbackModule(CallbackBase): class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0 CALLBACK_VERSION = 2.0
@ -39,8 +39,9 @@ class CallbackModule(CallbackBase):
super(CallbackModule, self).__init__(display=display) super(CallbackModule, self).__init__(display=display)
if not HAS_XMPP: if not HAS_XMPP:
print ("The required python xmpp library (xmpppy) is not installed" self._display.warning("The required python xmpp library (xmpppy) is not installed."
" pip install git+https://github.com/ArchipelProject/xmpppy") " pip install git+https://github.com/ArchipelProject/xmpppy")
self.disabled = True
self.serv = os.getenv('JABBER_SERV') self.serv = os.getenv('JABBER_SERV')
self.j_user = os.getenv('JABBER_USER') self.j_user = os.getenv('JABBER_USER')
@ -73,7 +74,6 @@ class CallbackModule(CallbackBase):
"""Display Playbook and play start messages""" """Display Playbook and play start messages"""
self.play = play self.play = play
name = play.name name = play.name
playbook = play.name
self.send_msg("Ansible starting play: %s" % (name)) self.send_msg("Ansible starting play: %s" % (name))
def playbook_on_stats(self, stats): def playbook_on_stats(self, stats):

@ -76,7 +76,7 @@ class CallbackModule(CallbackBase):
'stats': summary 'stats': summary
} }
print(json.dumps(output, indent=4, sort_keys=True)) self._display.display(json.dumps(output, indent=4, sort_keys=True))
v2_runner_on_failed = v2_runner_on_ok v2_runner_on_failed = v2_runner_on_ok
v2_runner_on_unreachable = v2_runner_on_ok v2_runner_on_unreachable = v2_runner_on_ok

Loading…
Cancel
Save