diff --git a/openflexure_microscope/api/default_extensions/__init__.py b/openflexure_microscope/api/default_extensions/__init__.py index b3bd9b69..6d9a592d 100644 --- a/openflexure_microscope/api/default_extensions/__init__.py +++ b/openflexure_microscope/api/default_extensions/__init__.py @@ -1,4 +1,14 @@ +import logging +import traceback + from .autofocus import autofocus_extension_v2 from .scan import scan_extension_v2 from .zip_builder import zip_extension_v2 -from .picamera_autocalibrate import lst_extension_v2 + +# "Gracefully" handle cases where picamera cannot be imported (eg test server) +try: + from .picamera_autocalibrate import lst_extension_v2 +except Exception as e: + logging.error( + f"Exception loading builtin extension picamera_autocalibrate: \n{traceback.format_exc()}" + ) \ No newline at end of file diff --git a/openflexure_microscope/common/flask_labthings/extensions.py b/openflexure_microscope/common/flask_labthings/extensions.py index 1054f24b..11b7b083 100644 --- a/openflexure_microscope/common/flask_labthings/extensions.py +++ b/openflexure_microscope/common/flask_labthings/extensions.py @@ -36,7 +36,7 @@ class BaseExtension: self.actions = [] self.properties = [] - self.name = name + self._name = name self.description = get_docstring(self) self.version = str(version) @@ -57,9 +57,6 @@ class BaseExtension: view_id = cleaned_rule.replace("/", "_").replace("<", "").replace(">", "") - # Create a Python-safe route ID - logging.debug(view_id) - # Store route information in a dictionary d = {"rule": full_rule, "view": view_class, "kwargs": kwargs} @@ -82,8 +79,8 @@ class BaseExtension: self._meta[key] = val @property - def _name(self): - return self.name + def name(self): + return self._name @property def _name_python_safe(self): @@ -111,6 +108,7 @@ def find_instances_in_module(module, class_to_find): for attribute in dir(module): if not attribute.startswith("__"): if isinstance(getattr(module, attribute), class_to_find): + logging.debug(f"Found extension {getattr(module, attribute).name}") objs.append(getattr(module, attribute)) return objs