Added picamera import checker

This commit is contained in:
Joel Collins 2020-11-06 10:36:31 +00:00
parent b98522a424
commit 013aebd97a
2 changed files with 19 additions and 2 deletions

View file

@ -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:

View file

@ -0,0 +1,15 @@
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