summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2016-11-01 13:16:16 +0100
committerJan Cholasta <jcholast@redhat.com>2016-11-11 12:13:56 +0100
commit5249eb817efbb5708d097173a8d5f1e322fb201e (patch)
tree9900eb6126fb11d2cadc18aef2016e83768e7858 /client
parentc38ce49e8d280e52c61f722b0e5ad7aa9f53cc1a (diff)
downloadfreeipa-5249eb817efbb5708d097173a8d5f1e322fb201e.tar.gz
freeipa-5249eb817efbb5708d097173a8d5f1e322fb201e.tar.xz
freeipa-5249eb817efbb5708d097173a8d5f1e322fb201e.zip
client: use exceptions instead of return states
Python has builtin exceptions which can be used very well to handling errors in python instead of returning error states (C style) Exception will allow better client-server integration in future https://fedorahosted.org/freeipa/ticket/6392 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
Diffstat (limited to 'client')
-rwxr-xr-xclient/ipa-client-install19
1 files changed, 9 insertions, 10 deletions
diff --git a/client/ipa-client-install b/client/ipa-client-install
index ab80bab2d..9ce26976a 100755
--- a/client/ipa-client-install
+++ b/client/ipa-client-install
@@ -30,6 +30,7 @@ from ipaclient.install import client
from ipapython.ipa_log_manager import standard_logging_setup, root_logger
from ipaplatform.paths import paths
from ipapython import version
+from ipapython.admintool import ScriptError
from ipapython.config import IPAOptionParser
from ipalib import x509
from ipalib.util import normalize_hostname, validate_domain_name
@@ -230,21 +231,19 @@ def main():
root_logger.debug('IPA version %s' % version.VENDOR_VERSION)
if options.uninstall:
- rval_check = client.uninstall_check(options)
- if rval_check != client.SUCCESS:
- return rval_check
-
- return client.uninstall(options)
+ client.uninstall_check(options)
+ client.uninstall(options)
else:
- rval_check = client.install_check(options)
- if rval_check != client.SUCCESS:
- return rval_check
-
- return client.install(options)
+ client.install_check(options)
+ client.install(options)
if __name__ == "__main__":
try:
sys.exit(main())
+ except ScriptError as e:
+ if e.rval != client.SUCCESS and e.msg:
+ root_logger.error(e.msg)
+ sys.exit(e.rval)
except KeyboardInterrupt:
sys.exit(1)
except RuntimeError as e: