Commit bc5c410a authored by Joel Collins's avatar Joel Collins
Browse files

Better handling of default extension exceptions

parent 94aac619
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
import logging
import traceback

from .autofocus import autofocus_extension_v2
from .scan import scan_extension_v2
from .zip_builder import zip_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
+4 −6
Original line number Diff line number Diff line
@@ -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