aics-int / microscope_automation

Automation software for the AICS Microscopes.
Other
4 stars 0 forks source link

BUG: If macro is not found app continues without error message #29

Closed wiegraebe closed 3 years ago

wiegraebe commented 3 years ago

Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Description

If connect_zen_blue.run_macro does not find a macro (e.g. macro not defined in ZEN blue) nothing happens and the macro execution is skipped without error message. In the case self.Zen.Application.RunMacro(macro_name) returns 'Macro \'10x_stitch\' not found'.

Expected Behavior

User has the option to

Reproduction

Use for experiment RunMacro in preferences the setting:

RunMacro:
  FunctionName: run_macro                       # Name of function in Python code in module microscopeAutomation that will process this experiment
  MacroName: 10x_stitch                         # Name of macro called in Zen Blue software
  Folder: ['10XwellScan\TapeOnly\split', '100X_zstack_2hr\TapeOnly', '100X_zstack_4hr\TapeOnly', '100X_zstack_24hr\TapeOnly'] # List of folders inside daily foder to create before running macro if they do not exist.
  Experiment: NoExperiment

and do not define a macro of this name in ZEN blue.

Your code here

   def run_macro(self, macro_name, macro_param=None):
        """Function to run a given Zen Blue Macro

        Input:
         macro_name: Name of the macro

        Output:
         none
        """
        try:
            if macro_param is None:

                self.Zen.Application.RunMacro(macro_name)
            else:
                self.Zen.Application.RunMacro_2(macro_name, macro_param)

        except Exception as e:
            log(e)
            raise e

Environment

Any additional information about your environment

fletchapin commented 3 years ago

Based on this summary, it seems that self.Zen.Application.RunMacro doesn't throw an exception but instead returns a string "Macro '10x_stitch' not found", so we'll have to parse the output and prompt the user to decide whether an exception should be thrown or if they want to enter a new macro name

wiegraebe commented 3 years ago

Yes, you are correct. We have to parse the string.

wiegraebe commented 3 years ago

The macro can return other error messages we have to parse, e.g. 'C:\\Users\\winfriedw\\Documents\\Carl Zeiss\\ZEN\\Documents\\Macros\\10x_stitch.czmac(6):Could not find a part of the path \'D:\\Production\\3500003095\\ZSD1\\10XwellScan\\TapeOnly\'.' I think that self.Zen.Application.RunMacro(macro_name) returns error messages and does not raise an exception is a feature of the most recent Zeiss ZEN software, thus we have to handle exceptions and error messages.

wiegraebe commented 3 years ago

The return value is 'ok' if there was no problem.