Use sys.exit(msg) i/o print() and sys.exit() (#15465)

Any non-0 exits should be showing an error message
to stderr instead of to stdout.
This commit is contained in:
Adrian Likins 2016-08-23 11:09:23 -04:00 committed by Brian Coca
commit 57a911e098
10 changed files with 22 additions and 37 deletions

View file

@ -185,20 +185,14 @@ class LinodeInventory(object):
for node in Linode.search(status=Linode.STATUS_RUNNING):
self.add_node(node)
except chube_api.linode_api.ApiError as e:
print("Looks like Linode's API is down:")
print("")
print(e)
sys.exit(1)
sys.exit("Looks like Linode's API is down:\n %s" % e)
def get_node(self, linode_id):
"""Gets details about a specific node."""
try:
return Linode.find(api_id=linode_id)
except chube_api.linode_api.ApiError as e:
print("Looks like Linode's API is down:")
print("")
print(e)
sys.exit(1)
sys.exit("Looks like Linode's API is down:\n%" % e)
def populate_datacenter_cache(self):
"""Creates self._datacenter_cache, containing all Datacenters indexed by ID."""