diff --git a/TutorialMaker/TutorialMaker.py b/TutorialMaker/TutorialMaker.py index 843f5c9..9797596 100644 --- a/TutorialMaker/TutorialMaker.py +++ b/TutorialMaker/TutorialMaker.py @@ -440,6 +440,13 @@ def onComplete(): def Generate(self, tutorialName): modulePath = Lib.TutorialUtils.get_module_basepath("TutorialMaker") annotationsPath = modulePath + f"/Outputs/Annotations/{tutorialName}/annotations.json" + currentTutorial = None + try: + currentTutorial = os.environ["TUTORIAL_CURRENT_SELFTEST"] + except e: + pass + + os.environ["TUTORIAL_CURRENT_SELFTEST"] = tutorialName if not os.path.exists(annotationsPath): # In testing/CI mode, print warning instead of showing modal dialog @@ -458,9 +465,18 @@ def Generate(self, tutorialName): _("No Annotations Found") ) return + _exception = None + try: + AnnotationPainter.TutorialPainter().GenerateHTMLfromAnnotatedTutorial(annotationsPath) + except Exception as error: + if (os.environ.get('CI') == 'true' or os.environ.get('GITHUB_ACTIONS') == 'true'): + raise error + else: + _exception = error with slicer.util.tryWithErrorDisplay(_("Failed to generate tutorial")): - AnnotationPainter.TutorialPainter().GenerateHTMLfromAnnotatedTutorial(annotationsPath) + if _exception is not None: + raise _exception outputPath = modulePath + "/Outputs/" # Check if we're in testing/CI mode - check all possible indicators @@ -492,6 +508,8 @@ def Generate(self, tutorialName): # In testing/CI mode, just print the message print(f"✅ Tutorial Generated: {tutorialName}") print(f" Output path: {outputPath}") + + os.environ["TUTORIAL_CURRENT_SELFTEST"] = currentTutorial pass def CreateNewTutorial(self):