mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
narrow the scope of import error and make sure non - aliases to ansible get their own error
This commit is contained in:
parent
a7d1a39b81
commit
10fd717a44
1 changed files with 8 additions and 4 deletions
12
bin/ansible
12
bin/ansible
|
@ -71,11 +71,15 @@ if __name__ == '__main__':
|
|||
mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
|
||||
elif me == 'ansible':
|
||||
from ansible.cli.adhoc import AdHocCLI as mycli
|
||||
else:
|
||||
raise AnsibleError("Unknown Ansible alias: %s" % me)
|
||||
except ImportError as e:
|
||||
if e.message.endswith(' %s' % sub):
|
||||
raise AnsibleError("Ansible sub-program not implemented: %s" % me)
|
||||
else:
|
||||
raise
|
||||
|
||||
cli = mycli(sys.argv, display=display)
|
||||
except (ImportError,NameError):
|
||||
raise AnsibleError("Ansible sub-program not implemented: %s" % me)
|
||||
|
||||
cli = mycli(sys.argv, display=display)
|
||||
cli.parse()
|
||||
sys.exit(cli.run())
|
||||
|
||||
|
|
Loading…
Reference in a new issue