blob: 8681cb739d44e3055dfb23205f7b265ed0be9d09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/usr/bin/env python
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import cProfile
import sys
import traceback
import ansible.constants as C
from ansible.module_utils._text import to_text
target = sys.argv.pop(1)
myclass = "%sCLI" % target.capitalize()
try:
# define cli
mycli = getattr(__import__("ansible.cli.%s" % target, fromlist=[myclass]), myclass)
except ImportError as e:
msg = getattr(e, 'msg', getattr(e, message, ''))
if msg.endswith(' %s' % target):
raise Exception("Ansible sub-program not implemented: %s" % target)
else:
raise
try:
args = [to_text(a, errors='surrogate_or_strict') for a in sys.argv]
except UnicodeError:
sys.stderr.write(u"The full traceback was:\n\n%s" % to_text(traceback.format_exc()))
sys.exit(u'Command line args are parsable to utf-8')
# init cli
cli = mycli(args)
print(cli.__class__.version_info(gitinfo=True))
# parse args
cli.parse()
# run
cProfile.run('cli.run()')
|