diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-11-08 23:13:48 +0100 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2010-11-22 09:51:07 -0500 |
commit | 57e1edd052dda284be87e29e1e839af4a9324faf (patch) | |
tree | 00fa2924e12c309d6cef25056feed37212ef8cd7 /install/tools/ipa-compat-manage | |
parent | 3e540272c69c9697a52a0e2d04ed3c2ae93740f4 (diff) | |
download | freeipa-57e1edd052dda284be87e29e1e839af4a9324faf.tar.gz freeipa-57e1edd052dda284be87e29e1e839af4a9324faf.tar.xz freeipa-57e1edd052dda284be87e29e1e839af4a9324faf.zip |
Use sys.exit to quit scripts
Instead of print and return, use sys.exit() to quit scripts with an
error message and a non zero return code.
https://fedorahosted.org/freeipa/ticket/425
Diffstat (limited to 'install/tools/ipa-compat-manage')
-rwxr-xr-x | install/tools/ipa-compat-manage | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/install/tools/ipa-compat-manage b/install/tools/ipa-compat-manage index ded587d5b..508efd83c 100755 --- a/install/tools/ipa-compat-manage +++ b/install/tools/ipa-compat-manage @@ -74,11 +74,9 @@ def main(): loglevel = logging.DEBUG if len(args) != 1: - print "You must specify one action, either enable or disable" - sys.exit(1) + sys.exit("You must specify one action, either enable or disable") elif args[0] != "enable" and args[0] != "disable" and args[0] != "status": - print "Unrecognized action [" + args[0] + "]" - sys.exit(1) + sys.exit("Unrecognized action [" + args[0] + "]") logging.basicConfig(level=loglevel, format='%(levelname)s %(message)s') @@ -102,9 +100,7 @@ def main(): bind_dn='cn=directory manager', bind_pw=dirman_password ) except errors.LDAPError, lde: - print "An error occurred while connecting to the server." - print lde - return 1 + sys.exit("An error occurred while connecting to the server.\n%s\n" % str(lde)) if args[0] == "status": try: @@ -142,9 +138,9 @@ def main(): # We can't disable schema compat if the NIS plugin is enabled try: conn.get_entry(netgroup_compat_dn, normalize=False) - print "The NIS plugin is configured, cannot disable compatibility." - print "Run 'ipa-nis-manage disable' first." - return 2 + print >>sys.stderr, "The NIS plugin is configured, cannot disable compatibility." + print >>sys.stderr, "Run 'ipa-nis-manage disable' first." + sys.exit(2) except errors.NotFound: pass # Make a quick hack for now, directly delete the entries by name, |