Skip to content

Commit

Permalink
moved last utils.debug to display.debug
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoca committed Apr 8, 2016
1 parent dd32ba4 commit 005dc84
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 36 deletions.
15 changes: 10 additions & 5 deletions lib/ansible/executor/process/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
except ImportError:
HAS_ATFORK=False

from ansible.utils.debug import debug
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()


__all__ = ['ResultProcess']

Expand All @@ -57,9 +62,9 @@ def __init__(self, final_q, workers):
super(ResultProcess, self).__init__()

def _send_result(self, result):
debug(u"sending result: %s" % ([text_type(x) for x in result],))
display.debug(u"sending result: %s" % ([text_type(x) for x in result],))
self._final_q.put(result)
debug("done sending result")
display.debug("done sending result")

def _read_worker_result(self):
result = None
Expand All @@ -72,9 +77,9 @@ def _read_worker_result(self):

try:
if not rslt_q.empty():
debug("worker %d has data to read" % self._cur_worker)
display.debug("worker %d has data to read" % self._cur_worker)
result = rslt_q.get()
debug("got a result from worker %d: %s" % (self._cur_worker, result))
display.debug("got a result from worker %d: %s" % (self._cur_worker, result))
break
except queue.Empty:
pass
Expand Down
22 changes: 13 additions & 9 deletions lib/ansible/executor/process/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@
from ansible.playbook.handler import Handler
from ansible.playbook.task import Task
from ansible.vars.unsafe_proxy import AnsibleJSONUnsafeDecoder

from ansible.utils.debug import debug
from ansible.utils.unicode import to_unicode

try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()

__all__ = ['WorkerProcess']


Expand Down Expand Up @@ -104,7 +108,7 @@ def run(self):

try:
# execute the task and build a TaskResult from the result
debug("running TaskExecutor() for %s/%s" % (self._host, self._task))
display.debug("running TaskExecutor() for %s/%s" % (self._host, self._task))
executor_result = TaskExecutor(
self._host,
self._task,
Expand All @@ -116,15 +120,15 @@ def run(self):
self._rslt_q
).run()

debug("done running TaskExecutor() for %s/%s" % (self._host, self._task))
display.debug("done running TaskExecutor() for %s/%s" % (self._host, self._task))
self._host.vars = dict()
self._host.groups = []
task_result = TaskResult(self._host, self._task, executor_result)

# put the result on the result queue
debug("sending task result")
display.debug("sending task result")
self._rslt_q.put(task_result)
debug("done sending task result")
display.debug("done sending task result")

except AnsibleConnectionFailure:
self._host.vars = dict()
Expand All @@ -140,8 +144,8 @@ def run(self):
task_result = TaskResult(self._host, self._task, dict(failed=True, exception=to_unicode(traceback.format_exc()), stdout=''))
self._rslt_q.put(task_result, block=False)
except:
debug(u"WORKER EXCEPTION: %s" % to_unicode(e))
debug(u"WORKER TRACEBACK: %s" % to_unicode(traceback.format_exc()))
display.debug(u"WORKER EXCEPTION: %s" % to_unicode(e))
display.debug(u"WORKER TRACEBACK: %s" % to_unicode(traceback.format_exc()))

debug("WORKER PROCESS EXITING")
display.debug("WORKER PROCESS EXITING")

3 changes: 1 addition & 2 deletions lib/ansible/template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from ansible.template.safe_eval import safe_eval
from ansible.template.template import AnsibleJ2Template
from ansible.template.vars import AnsibleJ2Vars
from ansible.utils.debug import debug
from ansible.utils.unicode import to_unicode, to_str

try:
Expand Down Expand Up @@ -499,7 +498,7 @@ def _do_template(self, data, preserve_trailing_newlines=True, escape_backslashes
errmsg += "Make sure your variable name does not contain invalid characters like '-': %s" % to_str(te)
raise AnsibleUndefinedVariable(errmsg)
else:
debug("failing because of a type error, template data is: %s" % to_str(data))
display.debug("failing because of a type error, template data is: %s" % to_str(data))
raise AnsibleError("Unexpected templating type error occurred on (%s): %s" % (to_str(data),to_str(te)))

if preserve_trailing_newlines:
Expand Down
18 changes: 0 additions & 18 deletions lib/ansible/utils/debug.py

This file was deleted.

5 changes: 4 additions & 1 deletion samples/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

from ansible.playbook.play import Play
from ansible.playbook.task import Task
from ansible.utils.debug import debug

from ansible.utils.display import Display
display = Display()
debug = display.debug

NUM_WORKERS = 50
NUM_HOSTS = 2500
Expand Down
4 changes: 3 additions & 1 deletion samples/multi_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
from ansible.parsing.dataloader import DataLoader
from ansible.vars import VariableManager

from ansible.utils.debug import debug
from ansible.utils.display import Display
display = Display()
debug = display.debug

NUM_WORKERS = 20
NUM_HOSTS = 1778
Expand Down

0 comments on commit 005dc84

Please sign in to comment.