Nicely handle errors loading default extensions
This commit is contained in:
parent
f338b3b869
commit
1426848283
1 changed files with 24 additions and 12 deletions
|
|
@ -1,18 +1,30 @@
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from .autofocus import autofocus_extension_v2
|
@contextmanager
|
||||||
from .scan import scan_extension_v2
|
def handle_extension_error(extension_name):
|
||||||
from .zip_builder import zip_extension_v2
|
"""'gracefully' log an error if an extension fails to load."""
|
||||||
from .autostorage import autostorage_extension_v2
|
try:
|
||||||
from .camera_stage_mapping import csm_extension
|
yield
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(
|
||||||
|
f"Exception loading builtin extension picamera_autocalibrate: \n{traceback.format_exc()}"
|
||||||
|
)
|
||||||
|
|
||||||
# "Gracefully" handle cases where picamera cannot be imported (eg test server)
|
with handle_extension_error("autofocus"):
|
||||||
try:
|
from .autofocus import autofocus_extension_v2
|
||||||
|
with handle_extension_error("scan"):
|
||||||
|
from .scan import scan_extension_v2
|
||||||
|
with handle_extension_error("zip builder"):
|
||||||
|
from .zip_builder import zip_extension_v2
|
||||||
|
with handle_extension_error("autostorage"):
|
||||||
|
from .autostorage import autostorage_extension_v2
|
||||||
|
with handle_extension_error("camera stage mapping"):
|
||||||
|
from .camera_stage_mapping import csm_extension
|
||||||
|
with handle_extension_error("lens shading calibration"):
|
||||||
from .picamera_autocalibrate import lst_extension_v2
|
from .picamera_autocalibrate import lst_extension_v2
|
||||||
except Exception as e:
|
|
||||||
logging.error(
|
|
||||||
f"Exception loading builtin extension picamera_autocalibrate: \n{traceback.format_exc()}"
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..example_extensions.custom_element import customelement_extension_v2
|
#FIXME: this oughtn't stay in the production version...
|
||||||
|
with handle_extension_error("custom element example"):
|
||||||
|
from ..example_extensions.custom_element import customelement_extension_v2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue