Loading openflexure_microscope/api/v2/blueprints/actions/__init__.py +3 −7 Original line number Diff line number Diff line from flask import Blueprint, url_for, jsonify from sys import platform from openflexure_microscope.utilities import get_docstring from openflexure_microscope.api.views import MicroscopeView from . import camera, stage, system _actions = { "capture": { "rule": "/camera/capture/", "view_class": camera.CaptureAPI, "description": "Take a single still capture", "conditions": True, }, "preview_start": { "rule": "/camera/preview/start", "view_class": camera.GPUPreviewStartAPI, "description": "Start the on-board GPU preview", "conditions": True, }, "preview_stop": { "rule": "/camera/preview/stop", "view_class": camera.GPUPreviewStopAPI, "description": "Stop the on-board GPU preview", "conditions": True, }, "move": { "rule": "/stage/move/", "view_class": stage.MoveStageAPI, "description": "Move the microscope stage", "conditions": True, }, "shutdown": { "rule": "/system/shutdown/", "view_class": system.ShutdownAPI, "description": "Shutdown the device", "conditions": (platform == "linux"), }, "reboot": { "rule": "/system/reboot/", "view_class": system.RebootAPI, "description": "Reboot the device", "conditions": (platform == "linux"), }, } Loading @@ -57,7 +53,7 @@ def actions_representation(): for name, action in enabled_actions().items(): d = { "links": {"self": url_for(f".{name}")}, "description": action["description"], "description": get_docstring(action["view_class"]), "rule": action["rule"], "view_class": str(action["view_class"]), } Loading openflexure_microscope/api/v2/blueprints/actions/camera.py +18 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,12 @@ from flask import jsonify, request, abort, url_for, redirect, send_file class CaptureAPI(MicroscopeView): """ Create a new image capture. Allowed methods: POST """ def post(self): """ Create a new image capture. Loading Loading @@ -101,6 +107,12 @@ class CaptureAPI(MicroscopeView): class GPUPreviewStartAPI(MicroscopeView): """ Start the onboard GPU preview. Allowed methods: POST """ def post(self, operation): """ Start the onboard GPU preview. Loading Loading @@ -143,6 +155,12 @@ class GPUPreviewStartAPI(MicroscopeView): class GPUPreviewStopAPI(MicroscopeView): """ Stop the onboard GPU preview. Allowed methods: POST """ def post(self, operation): """ Stop the onboard GPU preview. Loading openflexure_microscope/api/v2/blueprints/actions/stage.py +6 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,12 @@ import logging class MoveStageAPI(MicroscopeView): """ Handle stage movements. Allowed methods: POST """ def post(self): """ Set x, y and z positions of the stage. Loading openflexure_microscope/api/v2/blueprints/actions/system.py +12 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,12 @@ import subprocess class ShutdownAPI(MicroscopeView): """ Attempt to shutdown the device Allowed methods: POST """ def post(self): """ Attempt to shutdown the device Loading @@ -17,6 +23,12 @@ class ShutdownAPI(MicroscopeView): class RebootAPI(MicroscopeView): """ Attempt to reboot the device Allowed methods: POST """ def post(self): """ Attempt to shutdown the device Loading openflexure_microscope/api/v2/blueprints/plugins.py +3 −2 Original line number Diff line number Diff line from openflexure_microscope.plugins import PluginLoader, MicroscopePlugin from openflexure_microscope.api.views import MicroscopeViewPlugin from openflexure_microscope.utilities import get_docstring from flask import Blueprint, jsonify, url_for from openflexure_microscope.api.views import MicroscopeView Loading Loading @@ -28,7 +29,7 @@ def plugins_representation(plugin_loader_object: PluginLoader): "plugin": str(plugin), "views": {}, "form": plugin.form, "description": plugin.__doc__.strip() if plugin.__doc__ else "" "description": get_docstring(plugin) } for view_id, view_data in plugin.views.items(): Loading @@ -36,7 +37,7 @@ def plugins_representation(plugin_loader_object: PluginLoader): uri = url_for(f"v2_plugins_blueprint.{view_id}") # Make links dictionary if it doesn't yet exist view_d = { "description": view_data["view"].__doc__.strip() if view_data["view"].__doc__ else "", "description": get_docstring(view_data["view"]), "links": {"self": uri} } Loading Loading
openflexure_microscope/api/v2/blueprints/actions/__init__.py +3 −7 Original line number Diff line number Diff line from flask import Blueprint, url_for, jsonify from sys import platform from openflexure_microscope.utilities import get_docstring from openflexure_microscope.api.views import MicroscopeView from . import camera, stage, system _actions = { "capture": { "rule": "/camera/capture/", "view_class": camera.CaptureAPI, "description": "Take a single still capture", "conditions": True, }, "preview_start": { "rule": "/camera/preview/start", "view_class": camera.GPUPreviewStartAPI, "description": "Start the on-board GPU preview", "conditions": True, }, "preview_stop": { "rule": "/camera/preview/stop", "view_class": camera.GPUPreviewStopAPI, "description": "Stop the on-board GPU preview", "conditions": True, }, "move": { "rule": "/stage/move/", "view_class": stage.MoveStageAPI, "description": "Move the microscope stage", "conditions": True, }, "shutdown": { "rule": "/system/shutdown/", "view_class": system.ShutdownAPI, "description": "Shutdown the device", "conditions": (platform == "linux"), }, "reboot": { "rule": "/system/reboot/", "view_class": system.RebootAPI, "description": "Reboot the device", "conditions": (platform == "linux"), }, } Loading @@ -57,7 +53,7 @@ def actions_representation(): for name, action in enabled_actions().items(): d = { "links": {"self": url_for(f".{name}")}, "description": action["description"], "description": get_docstring(action["view_class"]), "rule": action["rule"], "view_class": str(action["view_class"]), } Loading
openflexure_microscope/api/v2/blueprints/actions/camera.py +18 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,12 @@ from flask import jsonify, request, abort, url_for, redirect, send_file class CaptureAPI(MicroscopeView): """ Create a new image capture. Allowed methods: POST """ def post(self): """ Create a new image capture. Loading Loading @@ -101,6 +107,12 @@ class CaptureAPI(MicroscopeView): class GPUPreviewStartAPI(MicroscopeView): """ Start the onboard GPU preview. Allowed methods: POST """ def post(self, operation): """ Start the onboard GPU preview. Loading Loading @@ -143,6 +155,12 @@ class GPUPreviewStartAPI(MicroscopeView): class GPUPreviewStopAPI(MicroscopeView): """ Stop the onboard GPU preview. Allowed methods: POST """ def post(self, operation): """ Stop the onboard GPU preview. Loading
openflexure_microscope/api/v2/blueprints/actions/stage.py +6 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,12 @@ import logging class MoveStageAPI(MicroscopeView): """ Handle stage movements. Allowed methods: POST """ def post(self): """ Set x, y and z positions of the stage. Loading
openflexure_microscope/api/v2/blueprints/actions/system.py +12 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,12 @@ import subprocess class ShutdownAPI(MicroscopeView): """ Attempt to shutdown the device Allowed methods: POST """ def post(self): """ Attempt to shutdown the device Loading @@ -17,6 +23,12 @@ class ShutdownAPI(MicroscopeView): class RebootAPI(MicroscopeView): """ Attempt to reboot the device Allowed methods: POST """ def post(self): """ Attempt to shutdown the device Loading
openflexure_microscope/api/v2/blueprints/plugins.py +3 −2 Original line number Diff line number Diff line from openflexure_microscope.plugins import PluginLoader, MicroscopePlugin from openflexure_microscope.api.views import MicroscopeViewPlugin from openflexure_microscope.utilities import get_docstring from flask import Blueprint, jsonify, url_for from openflexure_microscope.api.views import MicroscopeView Loading Loading @@ -28,7 +29,7 @@ def plugins_representation(plugin_loader_object: PluginLoader): "plugin": str(plugin), "views": {}, "form": plugin.form, "description": plugin.__doc__.strip() if plugin.__doc__ else "" "description": get_docstring(plugin) } for view_id, view_data in plugin.views.items(): Loading @@ -36,7 +37,7 @@ def plugins_representation(plugin_loader_object: PluginLoader): uri = url_for(f"v2_plugins_blueprint.{view_id}") # Make links dictionary if it doesn't yet exist view_d = { "description": view_data["view"].__doc__.strip() if view_data["view"].__doc__ else "", "description": get_docstring(view_data["view"]), "links": {"self": uri} } Loading