Merge "use sys.exit() replace exit()"

This commit is contained in:
Jenkins 2016-01-27 20:15:58 +00:00 committed by Gerrit Code Review
commit 418a22fd68

View File

@ -115,6 +115,7 @@ import csv
import json import json
import os import os
import six import six
import sys
import yaml import yaml
from oslo_config import cfg from oslo_config import cfg
@ -359,14 +360,14 @@ def main():
if not config.list: if not config.list:
LOG.error("This program must be executed in list mode.") LOG.error("This program must be executed in list mode.")
exit(1) sys.exit(1)
(groups, hostvars) = _prepare_inventory() (groups, hostvars) = _prepare_inventory()
if 'BIFROST_INVENTORY_SOURCE' not in os.environ: if 'BIFROST_INVENTORY_SOURCE' not in os.environ:
LOG.error('Please define a BIFROST_INVENTORY_SOURCE environment' LOG.error('Please define a BIFROST_INVENTORY_SOURCE environment'
'variable with a comma separated list of data sources') 'variable with a comma separated list of data sources')
exit(1) sys.exit(1)
try: try:
data_source = os.environ['BIFROST_INVENTORY_SOURCE'] data_source = os.environ['BIFROST_INVENTORY_SOURCE']
@ -389,7 +390,7 @@ def main():
LOG.error("BIFROST_INVENTORY_SOURCE does not define " LOG.error("BIFROST_INVENTORY_SOURCE does not define "
"a file that could be processed: " "a file that could be processed: "
"Tried JSON, YAML, and CSV formats") "Tried JSON, YAML, and CSV formats")
exit(1) sys.exit(1)
elif "ironic" in data_source: elif "ironic" in data_source:
if SHADE_LOADED: if SHADE_LOADED:
(groups, hostvars) = _process_shade(groups, hostvars) (groups, hostvars) = _process_shade(groups, hostvars)
@ -397,14 +398,14 @@ def main():
LOG.error("BIFROST_INVENTORY_SOURCE is set to ironic " LOG.error("BIFROST_INVENTORY_SOURCE is set to ironic "
"however the shade library failed to load, and may " "however the shade library failed to load, and may "
"not be present.") "not be present.")
exit(1) sys.exit(1)
else: else:
LOG.error('BIFROST_INVENTORY_SOURCE does not define a file') LOG.error('BIFROST_INVENTORY_SOURCE does not define a file')
exit(1) sys.exit(1)
except Exception as error: except Exception as error:
LOG.error('Failed processing: %s' % error) LOG.error('Failed processing: %s' % error)
exit(1) sys.exit(1)
# General Data Conversion # General Data Conversion