From 28561433a01dcb69be3b545cb017aaefc5c7b90e Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 15 Apr 2019 19:14:31 +0100 Subject: [PATCH] Malformed capture db no longer crashes server --- openflexure_microscope/camera/base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openflexure_microscope/camera/base.py b/openflexure_microscope/camera/base.py index 6bc0bd35..6e396065 100644 --- a/openflexure_microscope/camera/base.py +++ b/openflexure_microscope/camera/base.py @@ -256,7 +256,12 @@ class BaseCamera(object): if os.path.isfile(db_path): # Load list of capture dictionary representations from db_path with open(db_path, 'r') as infile: - capture_dict_list = yaml.load(infile) + try: + capture_dict_list = yaml.load(infile) + except yaml.scanner.ScannerError as e: + logging.error(e) + logging.warning('Emptying malformed database. Your captures will not be deleted, but may not appear in the gallery.') + capture_dict_list = [] # Create capture object list, and validate captures capture_list = []