]> git.ipfire.org Git - nitsi.git/blobdiff - nitsi.in
Improve return codes
[nitsi.git] / nitsi.in
index 2090e0dafd7a928d05588114dcca4c64a7f4ff6c..51d5d86f78b0ad723742d3288578af0a8df6de0c 100755 (executable)
--- a/nitsi.in
+++ b/nitsi.in
@@ -4,6 +4,10 @@ from nitsi.test import test
 from nitsi.logger import init_logging
 import logging
 
+from nitsi.recipe import RecipeExeption
+
+from nitsi.test import TestException
+
 logger = logging.getLogger("nitsi")
 logger.setLevel(logging.DEBUG)
 # create console handler with a higher log level
@@ -36,15 +40,25 @@ if __name__ == "__main__":
         fh.setLevel(logging.DEBUG)
         logger.addHandler(fh)
         logger.debug("We now logging everything to {}/general.log".format(log_dir))
+        try:
+            currenttest = test(args.dir, log_dir)
+            currenttest.read_settings()
+            currenttest.virtual_environ_setup()
+            currenttest.load_recipe()
+        except RecipeExeption as e:
+            logger.exception(e)
+            exit(2)
 
-        currenttest = test(args.dir, log_dir)
-        currenttest.read_settings()
-        currenttest.virtual_environ_setup()
-        currenttest.load_recipe()
         try:
             currenttest.virtual_environ_start()
             currenttest.run_recipe()
+        except TestException as e:
+            logger.exception(e)
+            exit(1)
         except BaseException as e:
-            print(e)
+            logger.exception(e)
+            exit(3)
         finally:
-            currenttest.virtual_environ_stop()
\ No newline at end of file
+            currenttest.virtual_environ_stop()
+
+        exit(0)
\ No newline at end of file