From 3e70f3ea2abd3f6c855ff433b4b1ee5e0312417c Mon Sep 17 00:00:00 2001 From: Abhishek Koneru Date: Wed, 20 Mar 2013 17:28:10 -0400 Subject: Handle the Keyboard interrupt gracefully. Catch the KeyboardInterrupt (Ctrl-C) input during the execution of pkispawn and pkidestroy and display a proper message to user rather than a stacktrace. Ticket #536 --- base/deploy/src/pkidestroy | 8 ++++++++ base/deploy/src/pkispawn | 8 ++++++++ 2 files changed, 16 insertions(+) (limited to 'base/deploy/src') diff --git a/base/deploy/src/pkidestroy b/base/deploy/src/pkidestroy index 839e1cad5..98ac414ac 100755 --- a/base/deploy/src/pkidestroy +++ b/base/deploy/src/pkidestroy @@ -21,6 +21,8 @@ # System Imports import sys +import signal + if not hasattr(sys, "hexversion") or sys.hexversion < 0x020700f0: print "Python version %s.%s.%s is too old." % sys.version_info[:3] print "Please upgrade to at least Python 2.7.0." @@ -47,6 +49,11 @@ error was: """ % sys.exc_value sys.exit(1) +#Handle the Keyboard Interrupt +def interrupt_handler(signal, frame): + print + print '\nUninstallation canceled.' + sys.exit(1) # PKI Deployment Functions def main(argv): @@ -251,4 +258,5 @@ def main(argv): # PKI Deployment Entry Point if __name__ == "__main__": + signal.signal(signal.SIGINT, interrupt_handler) main(sys.argv) diff --git a/base/deploy/src/pkispawn b/base/deploy/src/pkispawn index 65bbaa4a8..447240ecf 100755 --- a/base/deploy/src/pkispawn +++ b/base/deploy/src/pkispawn @@ -21,6 +21,8 @@ # System Imports import sys +import signal + if not hasattr(sys, "hexversion") or sys.hexversion < 0x020700f0: print "Python version %s.%s.%s is too old." % sys.version_info[:3] print "Please upgrade to at least Python 2.7.0." @@ -50,6 +52,11 @@ error was: """ % sys.exc_value sys.exit(1) +#Handle the Keyboard Interrupt +def interrupt_handler(signal, frame): + print + print '\nInstallation canceled.' + sys.exit(1) # PKI Deployment Functions def main(argv): @@ -402,4 +409,5 @@ def main(argv): # PKI Deployment Entry Point if __name__ == "__main__": + signal.signal(signal.SIGINT, interrupt_handler) main(sys.argv) -- cgit