From 0ca29fac9af4cd437a8536f28ffd25923ec3f8cd Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 31 May 2012 14:34:09 +0200 Subject: Move install script error handling to a common function All of our install/admin scripts had a try/except block calling the main function and handling common exceptions. These were copy-pasted from each other and modified to various levels of sophistication. This refactors them out of installers to a single function, which includes a final pass/fail message for all of the scripts. Non-install scripts that set up the same log handler levels for stderr and log file are not changed, as it's not possible to log to only the logfile without changing the logger configuration. https://fedorahosted.org/freeipa/ticket/2071 --- install/tools/ipa-nis-manage | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'install/tools/ipa-nis-manage') diff --git a/install/tools/ipa-nis-manage b/install/tools/ipa-nis-manage index 5c5bbca8e..1c6de7b57 100755 --- a/install/tools/ipa-nis-manage +++ b/install/tools/ipa-nis-manage @@ -200,24 +200,5 @@ def main(): return retval -try: - if __name__ == "__main__": - sys.exit(main()) -except BadSyntax, e: - print "There is a syntax error in this update file:" - print " %s" % e - sys.exit(1) -except RuntimeError, e: - print "%s" % e - sys.exit(1) -except SystemExit, e: - sys.exit(e) -except KeyboardInterrupt, e: - sys.exit(1) -except config.IPAConfigError, e: - print "An IPA server to update cannot be found. Has one been configured yet?" - print "The error was: %s" % e - sys.exit(1) -except errors.LDAPError, e: - print "An error occurred while performing operations: %s" % e - sys.exit(1) +if __name__ == '__main__': + installutils.run_script(main, operation_name='ipa-nis-manage') -- cgit