Fixed broken references to capture list
This commit is contained in:
parent
45ee112e6f
commit
a34214b9fb
5 changed files with 29 additions and 17 deletions
|
|
@ -80,7 +80,7 @@ class ZipManager:
|
||||||
|
|
||||||
# Get array of captures from IDs
|
# Get array of captures from IDs
|
||||||
capture_list = [
|
capture_list = [
|
||||||
microscope.camera.images.get(capture_id) for capture_id in capture_id_list
|
microscope.captures.images.get(capture_id) for capture_id in capture_id_list
|
||||||
]
|
]
|
||||||
# Remove Nones from list (missing/invalid captures)
|
# Remove Nones from list (missing/invalid captures)
|
||||||
capture_list = [capture for capture in capture_list if capture]
|
capture_list = [capture for capture in capture_list if capture]
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class CaptureList(View):
|
||||||
List all image captures
|
List all image captures
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
image_list = microscope.camera.images.values()
|
image_list = microscope.captures.images.values()
|
||||||
return image_list
|
return image_list
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ class CaptureView(View):
|
||||||
Description of a single image capture
|
Description of a single image capture
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.images.get(id)
|
capture_obj = microscope.captures.images.get(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
return abort(404) # 404 Not Found
|
return abort(404) # 404 Not Found
|
||||||
|
|
@ -124,7 +124,7 @@ class CaptureView(View):
|
||||||
Delete a single image capture
|
Delete a single image capture
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.images.get(id)
|
capture_obj = microscope.captures.images.get(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
return abort(404) # 404 Not Found
|
return abort(404) # 404 Not Found
|
||||||
|
|
@ -132,7 +132,7 @@ class CaptureView(View):
|
||||||
# Delete the capture file
|
# Delete the capture file
|
||||||
capture_obj.delete()
|
capture_obj.delete()
|
||||||
# Delete from capture list
|
# Delete from capture list
|
||||||
del microscope.camera.images[id]
|
del microscope.captures.images[id]
|
||||||
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ class CaptureDownload(View):
|
||||||
Image data for a single image capture
|
Image data for a single image capture
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.images.get(id)
|
capture_obj = microscope.captures.images.get(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
return abort(404) # 404 Not Found
|
return abort(404) # 404 Not Found
|
||||||
|
|
@ -180,7 +180,7 @@ class CaptureTags(View):
|
||||||
Get tags associated with a single image capture
|
Get tags associated with a single image capture
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.images.get(id)
|
capture_obj = microscope.captures.images.get(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
return abort(404) # 404 Not Found
|
return abort(404) # 404 Not Found
|
||||||
|
|
@ -192,7 +192,7 @@ class CaptureTags(View):
|
||||||
Add tags to a single image capture
|
Add tags to a single image capture
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.images.get(id)
|
capture_obj = microscope.captures.images.get(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
return abort(404) # 404 Not Found
|
return abort(404) # 404 Not Found
|
||||||
|
|
@ -212,7 +212,7 @@ class CaptureTags(View):
|
||||||
Delete tags from a single image capture
|
Delete tags from a single image capture
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.images.get(id)
|
capture_obj = microscope.captures.images.get(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
return abort(404) # 404 Not Found
|
return abort(404) # 404 Not Found
|
||||||
|
|
@ -235,7 +235,7 @@ class CaptureAnnotations(View):
|
||||||
Get annotations associated with a single image capture
|
Get annotations associated with a single image capture
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.images.get(id)
|
capture_obj = microscope.captures.images.get(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
return abort(404) # 404 Not Found
|
return abort(404) # 404 Not Found
|
||||||
|
|
@ -247,7 +247,7 @@ class CaptureAnnotations(View):
|
||||||
Update metadata for a single image capture
|
Update metadata for a single image capture
|
||||||
"""
|
"""
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.images.get(id)
|
capture_obj = microscope.captures.images.get(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
return abort(404) # 404 Not Found
|
return abort(404) # 404 Not Found
|
||||||
|
|
|
||||||
|
|
@ -79,12 +79,6 @@ class BaseCamera(metaclass=ABCMeta):
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Close the BaseCamera and all attached StreamObjects."""
|
"""Close the BaseCamera and all attached StreamObjects."""
|
||||||
logging.info("Closing {}".format(self))
|
logging.info("Closing {}".format(self))
|
||||||
# Close all StreamObjects
|
|
||||||
for capture_list in [self.images.values(), self.videos.values()]:
|
|
||||||
for stream_object in capture_list:
|
|
||||||
stream_object.close()
|
|
||||||
# Empty temp directory
|
|
||||||
self.clear_tmp()
|
|
||||||
# Stop worker thread
|
# Stop worker thread
|
||||||
self.stop_worker()
|
self.stop_worker()
|
||||||
logging.info("Closed {}".format(self))
|
logging.info("Closed {}".format(self))
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,23 @@ class CaptureManager:
|
||||||
|
|
||||||
# FILE MANAGEMENT
|
# FILE MANAGEMENT
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
"""Create camera on context enter."""
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
|
"""Close camera stream on context exit."""
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
logging.info("Closing {}".format(self))
|
||||||
|
# Close all StreamObjects
|
||||||
|
for capture_list in [self.images.values(), self.videos.values()]:
|
||||||
|
for stream_object in capture_list:
|
||||||
|
stream_object.close()
|
||||||
|
# Empty temp directory
|
||||||
|
self.clear_tmp()
|
||||||
|
|
||||||
def clear_tmp(self):
|
def clear_tmp(self):
|
||||||
"""
|
"""
|
||||||
Removes all files in the temporary capture directories
|
Removes all files in the temporary capture directories
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ class Microscope:
|
||||||
self.camera.close()
|
self.camera.close()
|
||||||
if self.stage:
|
if self.stage:
|
||||||
self.stage.close()
|
self.stage.close()
|
||||||
|
self.captures.close()
|
||||||
logging.info("Closed {}".format(self))
|
logging.info("Closed {}".format(self))
|
||||||
|
|
||||||
def setup(self, configuration):
|
def setup(self, configuration):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue