From 0eb67a00f566fed9cd4a6f2b3611758906a80eae Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 7 Aug 2013 18:49:47 +0200 Subject: [PATCH] exit = 2 if ctrl-c is pressed, cleanup Signed-off-by: Nico Schottelius --- scripts/cdist | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/cdist b/scripts/cdist index 935e9096..83035f5d 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -116,10 +116,19 @@ def commandline(): # Work around python 3.3 bug: # http://bugs.python.org/issue16308 # http://bugs.python.org/issue9253 + + # FIXME: catching AttributeError also hides + # real problems.. try a different way + + # FIXME: we always print main help, not + # the help of the actual parser being used! try: - args.func(args) + getattr(args, "func") except AttributeError: parser['main'].print_help() + sys.exit(0) + + args.func(args) #def install(args): # configinstall(args, mode=cdist.install.Install) @@ -158,12 +167,10 @@ if __name__ == "__main__": commandline() except KeyboardInterrupt: - pass + exit_code = 2 except cdist.Error as e: log.error(e) exit_code = 1 - # Determine exit code by return value of function - sys.exit(exit_code)