From ce3297c46cb20fc155837480894053eedf88f164 Mon Sep 17 00:00:00 2001 From: caoyue Date: Mon, 25 Jan 2016 17:33:30 +0800 Subject: [PATCH] use sys.exit() replace exit() exit() is used for interactive shell, it relies on the site module. sys.exit() is considered good to use in programs. Change-Id: I77169ce6bf6e2c778013b1260f68093e95178b7f --- bifrost/inventory.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bifrost/inventory.py b/bifrost/inventory.py index d96cf0371..276371cf0 100755 --- a/bifrost/inventory.py +++ b/bifrost/inventory.py @@ -115,6 +115,7 @@ import csv import json import os import six +import sys import yaml from oslo_config import cfg @@ -359,14 +360,14 @@ def main(): if not config.list: LOG.error("This program must be executed in list mode.") - exit(1) + sys.exit(1) (groups, hostvars) = _prepare_inventory() if 'BIFROST_INVENTORY_SOURCE' not in os.environ: LOG.error('Please define a BIFROST_INVENTORY_SOURCE environment' 'variable with a comma separated list of data sources') - exit(1) + sys.exit(1) try: data_source = os.environ['BIFROST_INVENTORY_SOURCE'] @@ -389,7 +390,7 @@ def main(): LOG.error("BIFROST_INVENTORY_SOURCE does not define " "a file that could be processed: " "Tried JSON, YAML, and CSV formats") - exit(1) + sys.exit(1) elif "ironic" in data_source: if SHADE_LOADED: (groups, hostvars) = _process_shade(groups, hostvars) @@ -397,14 +398,14 @@ def main(): LOG.error("BIFROST_INVENTORY_SOURCE is set to ironic " "however the shade library failed to load, and may " "not be present.") - exit(1) + sys.exit(1) else: LOG.error('BIFROST_INVENTORY_SOURCE does not define a file') - exit(1) + sys.exit(1) except Exception as error: LOG.error('Failed processing: %s' % error) - exit(1) + sys.exit(1) # General Data Conversion