diff --git a/installsystems/image.py b/installsystems/image.py index b3bbdf651c89c14fa3f52cd12ff189bf46aed334..580cc3c7a0db5698c8968c2a4a77f6ec2040c101 100644 --- a/installsystems/image.py +++ b/installsystems/image.py @@ -223,8 +223,14 @@ class Image(object): # we need installsystems.printer to conserve arrow level sysmodules["installsystems.printer"] = installsystems.printer exec bytecode in global_dict + except SystemExit as e: + # skip a script which call exit(0) or exit() + if e.code is None or e.code == 0: + return + else: + raise ISError(u"Script %s exits with status" % path, e) except Exception as e: - raise ISError(u"Unable to execute script %s" % path, e) + raise ISError(u"Fail to execute script %s" % path, e) finally: sysmodules.clear() sysmodules.update(sysmodules_backup) diff --git a/installsystems/template.py b/installsystems/template.py index b9a3fe7411c812e28039b862b7c97212c4e1d4f3..77bf6fd9a2a1483be2e404e8f494f8726d7ab868 100644 --- a/installsystems/template.py +++ b/installsystems/template.py @@ -49,6 +49,8 @@ parser = """# -*- python -*- # global image object is a reference to current image # global parser object is your installsystems subparser (argparse) +# you can use exit() to break the execution of the script + import os import argparse from installsystems.printer import arrow @@ -72,6 +74,8 @@ setup = u"""# -*- python -*- # global image object is a reference to current image # namespace object is the persistant, it can be used to store data accross scripts +# you can use exit() to break the execution of the script + from installsystems.printer import arrow arrow(u"hostname: %s" % namespace.hostname)