Commit 013aebd9 authored by Joel Collins's avatar Joel Collins
Browse files

Added picamera import checker

parent b98522a4
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ from openflexure_microscope.paths import (
    PREFERRED_OPENFLEXURE_VAR_PATH,
)

from . import check_capture_reload, check_settings
from . import check_capture_reload, check_settings, check_picamera

# Paths for suggestions
LOGS_PATHS = [
@@ -49,6 +49,7 @@ error_keys = {
    "default_config_error": f"The default configuration file could not be parsed. To fix, consider backing up and deleting your configuration files from {CONFIG_PATHS} to reset the configuration.",
    "default_settings_error": f"The default settings file could not be parsed. To fix, consider backing up and deleting your configuration files from {SETTINGS_PATHS} to reset the configuration.",
    "capture_rebuild_timeout": f"Capture database rebuilding took a long time. This may not cause catastrophic errors, but rather will cause the server to hang for a while. To fix, consider moving your captures from {DATA_PATHS} to another location.",
    "picamera_import_error": "Picamera module could not be imported. Check physical connections to the camera as it may be damaged."
}

if __name__ == "__main__":
@@ -60,7 +61,8 @@ if __name__ == "__main__":
        error_sources = list(error_keys.keys())

    error_sources.extend(check_settings.main())
    error_sources.extend(check_capture_reload.main())
    error_sources.extend(check_picamera.main())
    #error_sources.extend(check_capture_reload.main())

    if not error_sources:

+15 −0
Original line number Diff line number Diff line
import logging

def main():
    error_sources = []
    logging.info("Attempting to import picamera...")

    try:
        from picamerax import PiCamera
    except Exception as e:  # pylint: disable=W0703
        # TODO: Parse exception object for a few different issues, and append different error sources
        # E.g. pi with camera already in use, disconnected, unsupported OS, etc
        logging.error(e)
        error_sources.append("picamera_import_error")

    return error_sources
 No newline at end of file