changeset 98:5959a117a943

Exit with the proper code.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 08 Sep 2014 00:04:29 -0700
parents 00a9b24ca944
children 8703be118430
files piecrust/main.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/main.py	Sun Sep 07 23:49:09 2014 -0700
+++ b/piecrust/main.py	Mon Sep 08 00:04:29 2014 -0700
@@ -54,13 +54,14 @@
     argv = sys.argv
     pre_args = _pre_parse_chef_args(argv)
     try:
-        return _run_chef(pre_args)
+        exit_code = _run_chef(pre_args)
     except Exception as ex:
         if pre_args.debug:
             logger.exception(ex)
         else:
             log_friendly_exception(logger, ex)
-        return 1
+        exit_code = 1
+    sys.exit(exit_code)
 
 
 class PreParsedChefArgs(object):
@@ -201,5 +202,10 @@
     # Run the command!
     ctx = CommandContext(app, parser, result)
     exit_code = result.func(ctx)
+    if exit_code is None:
+        return 0
+    if not isinstance(exit_code, int):
+        logger.error("Got non-integer exit code: %s" % exit_code)
+        return -1
     return exit_code