mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-12 03:14:24 -07:00
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:
parent
76f9935634
commit
57a911e098
10 changed files with 22 additions and 37 deletions
|
@ -147,8 +147,7 @@ except ImportError:
|
|||
try:
|
||||
from dopy.manager import DoManager
|
||||
except ImportError as e:
|
||||
print("failed=True msg='`dopy` library required for this script'")
|
||||
sys.exit(1)
|
||||
sys.exit("failed=True msg='`dopy` library required for this script'")
|
||||
|
||||
|
||||
|
||||
|
@ -178,9 +177,9 @@ class DigitalOceanInventory(object):
|
|||
|
||||
# Verify credentials were set
|
||||
if not hasattr(self, 'api_token'):
|
||||
print('''Could not find values for DigitalOcean api_token.
|
||||
sys.stderr.write('''Could not find values for DigitalOcean api_token.
|
||||
They must be specified via either ini file, command line argument (--api-token),
|
||||
or environment variables (DO_API_TOKEN)''')
|
||||
or environment variables (DO_API_TOKEN)\n''')
|
||||
sys.exit(-1)
|
||||
|
||||
# env command, show DigitalOcean credentials
|
||||
|
@ -196,7 +195,7 @@ or environment variables (DO_API_TOKEN)''')
|
|||
self.load_from_cache()
|
||||
if len(self.data) == 0:
|
||||
if self.args.force_cache:
|
||||
print('''Cache is empty and --force-cache was specified''')
|
||||
sys.stderr.write('''Cache is empty and --force-cache was specified\n''')
|
||||
sys.exit(-1)
|
||||
|
||||
self.manager = DoManager(None, self.api_token, api_version=2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue