diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2017-12-06 10:29:17 +0530 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2017-12-14 22:03:08 -0500 |
commit | 36f82ae8cc35415123ca4a69fe79e9a50388862b (patch) | |
tree | e6d5abc7ba8def82b923996fe03c6c2d40fe5ac9 /contrib | |
parent | 0ca828ebab48b18a7c4bc1770efce96c6579b2df (diff) | |
download | ansible-36f82ae8cc35415123ca4a69fe79e9a50388862b.tar.gz |
Replace exit() with sys.exit()
This fix adds replacement for exit() to sys.exit(), as
exit() is not recommended way to exit from the program.
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/inventory/nagios_livestatus.py | 11 | ||||
-rwxr-xr-x | contrib/inventory/nagios_ndo.py | 10 |
2 files changed, 9 insertions, 12 deletions
diff --git a/contrib/inventory/nagios_livestatus.py b/contrib/inventory/nagios_livestatus.py index 9aaf0d9fc2..91c72dac60 100755 --- a/contrib/inventory/nagios_livestatus.py +++ b/contrib/inventory/nagios_livestatus.py @@ -34,6 +34,8 @@ Livestatus API: http://www.naemon.org/documentation/usersguide/livestatus.html import os import re import argparse +import sys + try: import configparser except ImportError: @@ -44,8 +46,7 @@ import json try: from mk_livestatus import Socket except ImportError: - print("Error: mk_livestatus is needed. Try something like: pip install python-mk-livestatus") - exit(1) + sys.exit("Error: mk_livestatus is needed. Try something like: pip install python-mk-livestatus") class NagiosLivestatusInventory(object): @@ -160,8 +161,7 @@ class NagiosLivestatusInventory(object): self.json_indent = 2 if len(self.backends) == 0: - print("Error: Livestatus configuration is missing. See nagios_livestatus.ini.") - exit(1) + sys.exit("Error: Livestatus configuration is missing. See nagios_livestatus.ini.") for backend in self.backends: self.query_backend(backend, self.options.host) @@ -171,7 +171,6 @@ class NagiosLivestatusInventory(object): elif self.options.list: print(json.dumps(self.result, indent=self.json_indent)) else: - print("usage: --list or --host HOSTNAME [--pretty]") - exit(1) + sys.exit("usage: --list or --host HOSTNAME [--pretty]") NagiosLivestatusInventory() diff --git a/contrib/inventory/nagios_ndo.py b/contrib/inventory/nagios_ndo.py index cae142d289..e5377119c7 100755 --- a/contrib/inventory/nagios_ndo.py +++ b/contrib/inventory/nagios_ndo.py @@ -28,6 +28,7 @@ Configuration is read from `nagios_ndo.ini`. import os import argparse +import sys try: import configparser except ImportError: @@ -39,8 +40,7 @@ try: from sqlalchemy import text from sqlalchemy.engine import create_engine except ImportError: - print("Error: SQLAlchemy is needed. Try something like: pip install sqlalchemy") - exit(1) + sys.exit("Error: SQLAlchemy is needed. Try something like: pip install sqlalchemy") class NagiosNDOInventory(object): @@ -101,10 +101,8 @@ class NagiosNDOInventory(object): elif self.options.list: print(json.dumps(self.result)) else: - print("usage: --list or --host HOSTNAME") - exit(1) + sys.exit("usage: --list or --host HOSTNAME") else: - print("Error: Database configuration is missing. See nagios_ndo.ini.") - exit(1) + sys.exit("Error: Database configuration is missing. See nagios_ndo.ini.") NagiosNDOInventory() |