Loading openflexure_microscope/__init__.py +3 −1 Original line number Diff line number Diff line Loading @@ -4,3 +4,5 @@ __version__ = "0.1.0" from .microscope import Microscope from . import config from . import utilities from . import task from . import lock No newline at end of file openflexure_microscope/api/v1/blueprints/camera/capture.py +38 −40 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ class ListAPI(MicroscopeView): """ Get list of image captures. .. :quickref: Capture collection; Get collection of captures .. :quickref: Captures; Get collection of captures :>header Accept: application/json :query include_unavailable: return json representations of captures that have been completely deleted Loading Loading @@ -45,7 +45,7 @@ class ListAPI(MicroscopeView): """ Delete all captures (not yet implemented) .. :quickref: Capture collection; Delete all captures .. :quickref: Captures; Delete all captures """ for image in self.microscope.camera.images: image.delete() Loading @@ -58,7 +58,7 @@ class ListAPI(MicroscopeView): """ Create a new image capture. .. :quickref: Capture collection; New capture .. :quickref: Captures; New capture **Example request**: Loading Loading @@ -257,25 +257,6 @@ class CaptureAPI(MicroscopeView): class DownloadRedirectAPI(MicroscopeView): def get(self, capture_id): """ Redirect to download the capture under it's currently set filename. I.e., `/(capture_id)/download` will redirect to `/(capture_id)/download/(filename)`. .. :quickref: Capture; Redirect to download """ capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found thumbnail = get_bool(request.args.get('thumbnail')) return redirect(url_for('.capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307) class DownloadAPI(MicroscopeView): def get(self, capture_id, filename): """ Return image data for a capture. Loading @@ -283,7 +264,11 @@ class DownloadAPI(MicroscopeView): I.e., `/(capture_id)/download/foo.jpeg` will download the image as `foo.jpeg`, regardless of the capture's initially set filename. .. :quickref: Capture; Download capture file Route automatically redirects to download the capture under it's currently set filename. I.e., `/(capture_id)/download` will redirect to `/(capture_id)/download/(filename)`. .. :quickref: Capture; Download capture image **Example request**: Loading @@ -298,6 +283,7 @@ class DownloadAPI(MicroscopeView): :>header Content-Type: image/jpeg :status 200: capture data found :status 404: no capture found with that id """ capture_obj = self.microscope.camera.image_from_id(capture_id) Loading @@ -306,6 +292,19 @@ class DownloadAPI(MicroscopeView): thumbnail = get_bool(request.args.get('thumbnail')) return redirect(url_for('.capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307) class DownloadAPI(MicroscopeView): def get(self, capture_id, filename): capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found thumbnail = get_bool(request.args.get('thumbnail')) # If no filename is specified, redirect to the capture's currently set filename if not filename: return redirect(url_for('capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307) Loading @@ -323,23 +322,6 @@ class DownloadAPI(MicroscopeView): class MetadataRedirectAPI(MicroscopeView): def get(self, capture_id): """ Redirect to download the capture metadata under it's currently set filename. I.e., `/(capture_id)/download` will redirect to `/(capture_id)/download/(filename)`. .. :quickref: Capture; Redirect to metadata """ capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found return redirect(url_for('.metadata_download', capture_id=capture_id, filename=capture_obj.metadataname), code=307) class MetadataAPI(MicroscopeView): def get(self, capture_id, filename): """ Return metadatadata for a capture. Loading @@ -347,6 +329,10 @@ class MetadataAPI(MicroscopeView): I.e., `/(capture_id)/download/bar.yaml` will download the file as `bar.yaml`, regardless of the capture's initially set filename. Route automatically redirects to download the capture metadata under it's currently set filename. I.e., `/(capture_id)/download` will redirect to `/(capture_id)/download/(filename)`. .. :quickref: Capture; Download capture metadata **Example request**: Loading @@ -362,9 +348,21 @@ class MetadataAPI(MicroscopeView): :>header Content-Type: text/yaml :status 200: capture data found :status 404: no capture found with that id """ capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found return redirect(url_for('.metadata_download', capture_id=capture_id, filename=capture_obj.metadataname), code=307) class MetadataAPI(MicroscopeView): def get(self, capture_id, filename): capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found Loading openflexure_microscope/lock.py +7 −7 Original line number Diff line number Diff line Loading @@ -4,10 +4,10 @@ from openflexure_microscope.exceptions import LockError class StrictLock(object): def __init__(self, timeout=1): """ Class that behaves like a Python RLock, but with stricter timeout conditions and custom exceptions. """ def __init__(self, timeout=1): self._lock = RLock() self.timeout = timeout Loading @@ -29,11 +29,11 @@ class StrictLock(object): class CompositeLock(object): def __init__(self, locks, timeout=1): """ Class that behaves like a :py:class:`openflexure_microscope.lock.StrictLock`, but allows multiple locks to be acquired and released. """ def __init__(self, locks, timeout=1): self.locks = locks self.timeout = timeout Loading openflexure_microscope/microscope.py +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ class Microscope(object): self._config = config # Create a task orchestrator self.task = TaskOrchestrator() self.task = TaskOrchestrator() #: :py:class:`openflexure_microscope.task.TaskOrchestrator`: Threaded task orchestrator # Create plugin mountpoint self.plugin = PluginMount(self) #: :py:class:`openflexure_microscope.plugins.PluginMount`: Mounting point for all microscope plugins Loading openflexure_microscope/plugins/default/api.py +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ class IdentifyAPI(MicroscopeViewPlugin): """ Default plugin to return a plaintext representation of the camera and stage objects. .. :quickref: Default plugin; Show representation of camera and stage objects. .. :quickref: Default plugin; Identify hardware """ data = self.microscope.plugin.default.identify() # Call a method from our plugin, using the full route return Response(escape(data)) No newline at end of file Loading
openflexure_microscope/__init__.py +3 −1 Original line number Diff line number Diff line Loading @@ -4,3 +4,5 @@ __version__ = "0.1.0" from .microscope import Microscope from . import config from . import utilities from . import task from . import lock No newline at end of file
openflexure_microscope/api/v1/blueprints/camera/capture.py +38 −40 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ class ListAPI(MicroscopeView): """ Get list of image captures. .. :quickref: Capture collection; Get collection of captures .. :quickref: Captures; Get collection of captures :>header Accept: application/json :query include_unavailable: return json representations of captures that have been completely deleted Loading Loading @@ -45,7 +45,7 @@ class ListAPI(MicroscopeView): """ Delete all captures (not yet implemented) .. :quickref: Capture collection; Delete all captures .. :quickref: Captures; Delete all captures """ for image in self.microscope.camera.images: image.delete() Loading @@ -58,7 +58,7 @@ class ListAPI(MicroscopeView): """ Create a new image capture. .. :quickref: Capture collection; New capture .. :quickref: Captures; New capture **Example request**: Loading Loading @@ -257,25 +257,6 @@ class CaptureAPI(MicroscopeView): class DownloadRedirectAPI(MicroscopeView): def get(self, capture_id): """ Redirect to download the capture under it's currently set filename. I.e., `/(capture_id)/download` will redirect to `/(capture_id)/download/(filename)`. .. :quickref: Capture; Redirect to download """ capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found thumbnail = get_bool(request.args.get('thumbnail')) return redirect(url_for('.capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307) class DownloadAPI(MicroscopeView): def get(self, capture_id, filename): """ Return image data for a capture. Loading @@ -283,7 +264,11 @@ class DownloadAPI(MicroscopeView): I.e., `/(capture_id)/download/foo.jpeg` will download the image as `foo.jpeg`, regardless of the capture's initially set filename. .. :quickref: Capture; Download capture file Route automatically redirects to download the capture under it's currently set filename. I.e., `/(capture_id)/download` will redirect to `/(capture_id)/download/(filename)`. .. :quickref: Capture; Download capture image **Example request**: Loading @@ -298,6 +283,7 @@ class DownloadAPI(MicroscopeView): :>header Content-Type: image/jpeg :status 200: capture data found :status 404: no capture found with that id """ capture_obj = self.microscope.camera.image_from_id(capture_id) Loading @@ -306,6 +292,19 @@ class DownloadAPI(MicroscopeView): thumbnail = get_bool(request.args.get('thumbnail')) return redirect(url_for('.capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307) class DownloadAPI(MicroscopeView): def get(self, capture_id, filename): capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found thumbnail = get_bool(request.args.get('thumbnail')) # If no filename is specified, redirect to the capture's currently set filename if not filename: return redirect(url_for('capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307) Loading @@ -323,23 +322,6 @@ class DownloadAPI(MicroscopeView): class MetadataRedirectAPI(MicroscopeView): def get(self, capture_id): """ Redirect to download the capture metadata under it's currently set filename. I.e., `/(capture_id)/download` will redirect to `/(capture_id)/download/(filename)`. .. :quickref: Capture; Redirect to metadata """ capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found return redirect(url_for('.metadata_download', capture_id=capture_id, filename=capture_obj.metadataname), code=307) class MetadataAPI(MicroscopeView): def get(self, capture_id, filename): """ Return metadatadata for a capture. Loading @@ -347,6 +329,10 @@ class MetadataAPI(MicroscopeView): I.e., `/(capture_id)/download/bar.yaml` will download the file as `bar.yaml`, regardless of the capture's initially set filename. Route automatically redirects to download the capture metadata under it's currently set filename. I.e., `/(capture_id)/download` will redirect to `/(capture_id)/download/(filename)`. .. :quickref: Capture; Download capture metadata **Example request**: Loading @@ -362,9 +348,21 @@ class MetadataAPI(MicroscopeView): :>header Content-Type: text/yaml :status 200: capture data found :status 404: no capture found with that id """ capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found return redirect(url_for('.metadata_download', capture_id=capture_id, filename=capture_obj.metadataname), code=307) class MetadataAPI(MicroscopeView): def get(self, capture_id, filename): capture_obj = self.microscope.camera.image_from_id(capture_id) if not capture_obj or not capture_obj.state['available']: return abort(404) # 404 Not Found Loading
openflexure_microscope/lock.py +7 −7 Original line number Diff line number Diff line Loading @@ -4,10 +4,10 @@ from openflexure_microscope.exceptions import LockError class StrictLock(object): def __init__(self, timeout=1): """ Class that behaves like a Python RLock, but with stricter timeout conditions and custom exceptions. """ def __init__(self, timeout=1): self._lock = RLock() self.timeout = timeout Loading @@ -29,11 +29,11 @@ class StrictLock(object): class CompositeLock(object): def __init__(self, locks, timeout=1): """ Class that behaves like a :py:class:`openflexure_microscope.lock.StrictLock`, but allows multiple locks to be acquired and released. """ def __init__(self, locks, timeout=1): self.locks = locks self.timeout = timeout Loading
openflexure_microscope/microscope.py +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ class Microscope(object): self._config = config # Create a task orchestrator self.task = TaskOrchestrator() self.task = TaskOrchestrator() #: :py:class:`openflexure_microscope.task.TaskOrchestrator`: Threaded task orchestrator # Create plugin mountpoint self.plugin = PluginMount(self) #: :py:class:`openflexure_microscope.plugins.PluginMount`: Mounting point for all microscope plugins Loading
openflexure_microscope/plugins/default/api.py +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ class IdentifyAPI(MicroscopeViewPlugin): """ Default plugin to return a plaintext representation of the camera and stage objects. .. :quickref: Default plugin; Show representation of camera and stage objects. .. :quickref: Default plugin; Identify hardware """ data = self.microscope.plugin.default.identify() # Call a method from our plugin, using the full route return Response(escape(data)) No newline at end of file