mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
27 lines
562 B
Python
27 lines
562 B
Python
# Python
|
|
import os
|
|
import sys
|
|
|
|
# Based on http://stackoverflow.com/a/6879344/131141 -- Initialize tower display
|
|
# callback as early as possible to wrap ansible.display.Display methods.
|
|
|
|
|
|
def argv_ready(argv):
|
|
if argv and os.path.basename(argv[0]) in {'ansible', 'ansible-playbook'}:
|
|
import tower_display_callback # noqa
|
|
|
|
|
|
class argv_placeholder(object):
|
|
|
|
def __del__(self):
|
|
try:
|
|
argv_ready(sys.argv)
|
|
except:
|
|
pass
|
|
|
|
|
|
if hasattr(sys, 'argv'):
|
|
argv_ready(sys.argv)
|
|
else:
|
|
sys.argv = argv_placeholder()
|