mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
915 B
Python
39 lines
915 B
Python
8 years ago
|
#!/usr/bin/env python
|
||
1 year ago
|
from __future__ import annotations
|
||
8 years ago
|
|
||
|
import cProfile
|
||
|
import sys
|
||
|
import traceback
|
||
|
|
||
2 years ago
|
from ansible.module_utils.common.text.converters import to_text
|
||
8 years ago
|
|
||
|
target = sys.argv.pop(1)
|
||
|
myclass = "%sCLI" % target.capitalize()
|
||
1 year ago
|
module_name = f'ansible.cli.{target}'
|
||
8 years ago
|
|
||
|
try:
|
||
|
# define cli
|
||
1 year ago
|
mycli = getattr(__import__(module_name, fromlist=[myclass]), myclass)
|
||
8 years ago
|
except ImportError as e:
|
||
1 year ago
|
if module_name in e.msg:
|
||
|
raise Exception("Ansible sub-program not implemented: %s" % target) from None
|
||
8 years ago
|
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()')
|