Code cleanup in `ansible-inventory`.

pull/69557/head
Matt Clay 4 years ago
parent 159d79995c
commit ed4fd9be67

@ -0,0 +1,3 @@
bugfixes:
- Use ``sys.exit`` instead of ``exit`` in ``ansible-inventory``.
- Remove unused Python imports in ``ansible-inventory``.

@ -5,6 +5,8 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import sys
import argparse
from operator import attrgetter
@ -13,9 +15,7 @@ from ansible import context
from ansible.cli import CLI
from ansible.cli.arguments import option_helpers as opt_help
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.inventory.host import Host
from ansible.module_utils._text import to_bytes, to_native
from ansible.plugins.loader import vars_loader
from ansible.utils.vars import combine_vars
from ansible.utils.display import Display
from ansible.vars.plugins import get_vars_from_inventory_sources, get_vars_from_path
@ -161,9 +161,9 @@ class InventoryCLI(CLI):
f.write(results)
except (OSError, IOError) as e:
raise AnsibleError('Unable to write to destination file (%s): %s' % (to_native(outfile), to_native(e)))
exit(0)
sys.exit(0)
exit(1)
sys.exit(1)
@staticmethod
def dump(stuff):

Loading…
Cancel
Save