Fixed metadata and tags not storing to capture DB on update or exit

This commit is contained in:
Joel Collins 2019-02-13 15:17:52 +00:00
parent 7b7a8dfb4a
commit ed12cc7bce
3 changed files with 24 additions and 1 deletions

View file

@ -103,8 +103,15 @@ app.register_blueprint(task_blueprint, url_prefix=uri('/task', 'v1'))
def cleanup():
global api_microscope
logging.debug("App teardown started...")
# Save config
api_microscope.rc.save(backup=True)
if api_microscope.rc:
api_microscope.rc.save(backup=True)
# Update capture DB and metadata files before exiting
if api_microscope.camera:
api_microscope.camera.store_captures()
# Close down the microscope
api_microscope.close()
logging.debug("App teardown complete.")

View file

@ -278,6 +278,18 @@ class BaseCamera(object):
else:
return []
def store_captures(self):
# Save metadata files
for image in self.images:
image.save_metadata()
for video in self.videos:
video.save_metadata()
# Update capture database
self.save_capture_db(self.images, self.images_db)
self.save_capture_db(self.videos, self.videos_db)
# CREATING NEW CAPTURES
def shunt_captures(self, target_list: list):

View file

@ -50,6 +50,9 @@ def capture_from_dict(capture_dict):
if 'custom' in capture_dict['metadata']:
capture._metadata = capture_dict['metadata']['custom']
if 'tags' in capture_dict['metadata']:
capture.tags = capture_dict['metadata']['tags']
capture.file = capture_dict['metadata']['path']
capture.split_file_path(capture.file)
@ -246,6 +249,7 @@ class CaptureObject(object):
"""
if not tag in self.tags:
self.tags.append(tag)
self.save_metadata()
def delete_tag(self, tag: str):
"""