Commit a34214b9 authored by Joel Collins's avatar Joel Collins
Browse files

Fixed broken references to capture list

parent 45ee112e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ class ZipManager:

        # Get array of captures from IDs
        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)
        capture_list = [capture for capture in capture_list if capture]
+10 −10
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ class CaptureList(View):
        List all image captures
        """
        microscope = find_component("org.openflexure.microscope")
        image_list = microscope.camera.images.values()
        image_list = microscope.captures.images.values()
        return image_list


@@ -112,7 +112,7 @@ class CaptureView(View):
        Description of a single image capture
        """
        microscope = find_component("org.openflexure.microscope")
        capture_obj = microscope.camera.images.get(id)
        capture_obj = microscope.captures.images.get(id)

        if not capture_obj:
            return abort(404)  # 404 Not Found
@@ -124,7 +124,7 @@ class CaptureView(View):
        Delete a single image capture
        """
        microscope = find_component("org.openflexure.microscope")
        capture_obj = microscope.camera.images.get(id)
        capture_obj = microscope.captures.images.get(id)

        if not capture_obj:
            return abort(404)  # 404 Not Found
@@ -132,7 +132,7 @@ class CaptureView(View):
        # Delete the capture file
        capture_obj.delete()
        # Delete from capture list
        del microscope.camera.images[id]
        del microscope.captures.images[id]

        return "", 204

@@ -145,7 +145,7 @@ class CaptureDownload(View):
        Image data for a single image capture
        """
        microscope = find_component("org.openflexure.microscope")
        capture_obj = microscope.camera.images.get(id)
        capture_obj = microscope.captures.images.get(id)

        if not capture_obj:
            return abort(404)  # 404 Not Found
@@ -180,7 +180,7 @@ class CaptureTags(View):
        Get tags associated with a single image capture
        """
        microscope = find_component("org.openflexure.microscope")
        capture_obj = microscope.camera.images.get(id)
        capture_obj = microscope.captures.images.get(id)

        if not capture_obj:
            return abort(404)  # 404 Not Found
@@ -192,7 +192,7 @@ class CaptureTags(View):
        Add tags to a single image capture
        """
        microscope = find_component("org.openflexure.microscope")
        capture_obj = microscope.camera.images.get(id)
        capture_obj = microscope.captures.images.get(id)

        if not capture_obj:
            return abort(404)  # 404 Not Found
@@ -212,7 +212,7 @@ class CaptureTags(View):
        Delete tags from a single image capture
        """
        microscope = find_component("org.openflexure.microscope")
        capture_obj = microscope.camera.images.get(id)
        capture_obj = microscope.captures.images.get(id)

        if not capture_obj:
            return abort(404)  # 404 Not Found
@@ -235,7 +235,7 @@ class CaptureAnnotations(View):
        Get annotations associated with a single image capture
        """
        microscope = find_component("org.openflexure.microscope")
        capture_obj = microscope.camera.images.get(id)
        capture_obj = microscope.captures.images.get(id)

        if not capture_obj:
            return abort(404)  # 404 Not Found
@@ -247,7 +247,7 @@ class CaptureAnnotations(View):
        Update metadata for a single image capture
        """
        microscope = find_component("org.openflexure.microscope")
        capture_obj = microscope.camera.images.get(id)
        capture_obj = microscope.captures.images.get(id)

        if not capture_obj:
            return abort(404)  # 404 Not Found
+0 −6
Original line number Diff line number Diff line
@@ -79,12 +79,6 @@ class BaseCamera(metaclass=ABCMeta):
    def close(self):
        """Close the BaseCamera and all attached StreamObjects."""
        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
        self.stop_worker()
        logging.info("Closed {}".format(self))
+17 −0
Original line number Diff line number Diff line
@@ -52,6 +52,23 @@ class CaptureManager:

    # 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):
        """
        Removes all files in the temporary capture directories
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ class Microscope:
            self.camera.close()
        if self.stage:
            self.stage.close()
        self.captures.close()
        logging.info("Closed {}".format(self))

    def setup(self, configuration):