Loading openflexure_microscope/api/app.py +13 −19 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ app, labthing = create_app( app.json_encoder = JSONEncoder # Attach lab devices labthing.register_device(api_microscope, "org.openflexure.microscope") labthing.add_component(api_microscope, "org.openflexure.microscope") # Attach extensions if not os.path.isfile(USER_EXTENSIONS_PATH): Loading @@ -78,33 +78,27 @@ for extension in find_extensions(USER_EXTENSIONS_PATH): labthing.register_extension(extension) # Attach captures resources labthing.add_resource(views.CaptureList, f"/captures") labthing.register_property(views.CaptureList) labthing.add_resource(views.CaptureResource, f"/captures/<id>") labthing.add_resource(views.CaptureDownload, f"/captures/<id>/download/<filename>") labthing.add_resource(views.CaptureTags, f"/captures/<id>/tags") labthing.add_resource(views.CaptureMetadata, f"/captures/<id>/metadata") labthing.add_view(views.CaptureList, f"/captures") labthing.add_view(views.CaptureResource, f"/captures/<id>") labthing.add_view(views.CaptureDownload, f"/captures/<id>/download/<filename>") labthing.add_view(views.CaptureTags, f"/captures/<id>/tags") labthing.add_view(views.CaptureMetadata, f"/captures/<id>/metadata") # Attach settings and status resources labthing.add_resource(views.SettingsProperty, f"/settings") labthing.register_property(views.SettingsProperty) labthing.add_resource(views.NestedSettingsProperty, "/settings/<path:route>") labthing.add_resource(views.StatusProperty, "/status") labthing.register_property(views.StatusProperty) labthing.add_resource(views.NestedStatusProperty, "/status/<path:route>") labthing.add_view(views.SettingsProperty, f"/settings") labthing.add_view(views.NestedSettingsProperty, "/settings/<path:route>") labthing.add_view(views.StatusProperty, "/status") labthing.add_view(views.NestedStatusProperty, "/status/<path:route>") # Attach streams resources labthing.add_resource(views.MjpegStream, f"/streams/mjpeg") labthing.register_property(views.MjpegStream) labthing.add_resource(views.SnapshotStream, f"/streams/snapshot") labthing.register_property(views.SnapshotStream) labthing.add_view(views.MjpegStream, f"/streams/mjpeg") labthing.add_view(views.SnapshotStream, f"/streams/snapshot") # Attach microscope action resources for name, action in views.enabled_root_actions().items(): view_class = action["view_class"] rule = action["rule"] labthing.add_resource(view_class, f"/actions{rule}") labthing.register_action(view_class) labthing.add_view(view_class, f"/actions{rule}") @app.route("/routes") Loading openflexure_microscope/api/default_extensions/autofocus.py +6 −4 Original line number Diff line number Diff line from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.extensions import BaseExtension from openflexure_microscope.common.flask_labthings.resource import Resource from openflexure_microscope.common.flask_labthings.decorators import ( ThingAction, ThingProperty, ) from openflexure_microscope.devel import JsonResponse, request, jsonify, taskify, abort from openflexure_microscope.utilities import set_properties Loading Loading @@ -298,6 +302,7 @@ class MeasureSharpnessAPI(Resource): return jsonify({"sharpness": measure_sharpness(microscope)}) @ThingAction class AutofocusAPI(Resource): """ Run a standard autofocus Loading @@ -324,6 +329,7 @@ class AutofocusAPI(Resource): abort(503, "No stage connected. Unable to autofocus.") @ThingAction class FastAutofocusAPI(Resource): """ Run a fast autofocus Loading Loading @@ -359,9 +365,5 @@ autofocus_extension_v2.add_method(fast_autofocus, "fast_autofocus") autofocus_extension_v2.add_method(autofocus, "autofocus") autofocus_extension_v2.add_view(MeasureSharpnessAPI, "/measure_sharpness") autofocus_extension_v2.add_view(AutofocusAPI, "/autofocus") autofocus_extension_v2.register_action(AutofocusAPI) autofocus_extension_v2.add_view(FastAutofocusAPI, "/fast_autofocus") autofocus_extension_v2.register_action(FastAutofocusAPI) openflexure_microscope/api/default_extensions/scan.py +2 −2 Original line number Diff line number Diff line Loading @@ -12,8 +12,8 @@ from openflexure_microscope.common.flask_labthings.find import ( from openflexure_microscope.common.flask_labthings.extensions import BaseExtension from openflexure_microscope.common.flask_labthings.decorators import ( marshal_task, marshal_with, use_args, ThingAction, ) from openflexure_microscope.common.flask_labthings import fields Loading Loading @@ -340,6 +340,7 @@ def stack( ### Web views @ThingAction class TileScanAPI(Resource): @use_args( { Loading Loading @@ -398,4 +399,3 @@ class TileScanAPI(Resource): scan_extension_v2 = BaseExtension("scan") scan_extension_v2.add_view(TileScanAPI, "/tile") scan_extension_v2.register_action(TileScanAPI) openflexure_microscope/api/default_extensions/zip_builder.py +6 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,10 @@ import logging from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.resource import Resource from openflexure_microscope.common.flask_labthings.extensions import BaseExtension from openflexure_microscope.common.flask_labthings.decorators import ( ThingAction, ThingProperty, ) class ZipManager: Loading Loading @@ -91,6 +95,7 @@ class ZipManager: default_zip_manager = ZipManager() @ThingAction class ZipBuilderAPIView(Resource): def post(self): Loading @@ -103,6 +108,7 @@ class ZipBuilderAPIView(Resource): return jsonify(task.state), 201 @ThingProperty class ZipListAPIView(Resource): def get(self): return jsonify(default_zip_manager.session_zips) Loading Loading @@ -146,4 +152,3 @@ zip_extension_v2.add_view(ZipGetterAPIView, "/get/<string:session_id>") zip_extension_v2.add_view(ZipListAPIView, "/get") zip_extension_v2.add_view(ZipBuilderAPIView, "/build") zip_extension_v2.register_action(ZipBuilderAPIView) openflexure_microscope/api/example_extensions/ev_gui.py +6 −0 Original line number Diff line number Diff line from openflexure_microscope.common.flask_labthings.resource import Resource from openflexure_microscope.common.flask_labthings.extensions import BaseExtension from openflexure_microscope.common.flask_labthings.decorators import ( ThingAction, ThingProperty, ) from openflexure_microscope.api.utilities.gui import expand_routes Loading Loading @@ -72,6 +76,7 @@ static_form = { } @ThingProperty class TestAPIView(Resource): def get(self): global val_int Loading @@ -79,6 +84,7 @@ class TestAPIView(Resource): return jsonify({"val": True}) @ThingAction class TestDoAPIView(Resource): def post(self): global val_int Loading Loading
openflexure_microscope/api/app.py +13 −19 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ app, labthing = create_app( app.json_encoder = JSONEncoder # Attach lab devices labthing.register_device(api_microscope, "org.openflexure.microscope") labthing.add_component(api_microscope, "org.openflexure.microscope") # Attach extensions if not os.path.isfile(USER_EXTENSIONS_PATH): Loading @@ -78,33 +78,27 @@ for extension in find_extensions(USER_EXTENSIONS_PATH): labthing.register_extension(extension) # Attach captures resources labthing.add_resource(views.CaptureList, f"/captures") labthing.register_property(views.CaptureList) labthing.add_resource(views.CaptureResource, f"/captures/<id>") labthing.add_resource(views.CaptureDownload, f"/captures/<id>/download/<filename>") labthing.add_resource(views.CaptureTags, f"/captures/<id>/tags") labthing.add_resource(views.CaptureMetadata, f"/captures/<id>/metadata") labthing.add_view(views.CaptureList, f"/captures") labthing.add_view(views.CaptureResource, f"/captures/<id>") labthing.add_view(views.CaptureDownload, f"/captures/<id>/download/<filename>") labthing.add_view(views.CaptureTags, f"/captures/<id>/tags") labthing.add_view(views.CaptureMetadata, f"/captures/<id>/metadata") # Attach settings and status resources labthing.add_resource(views.SettingsProperty, f"/settings") labthing.register_property(views.SettingsProperty) labthing.add_resource(views.NestedSettingsProperty, "/settings/<path:route>") labthing.add_resource(views.StatusProperty, "/status") labthing.register_property(views.StatusProperty) labthing.add_resource(views.NestedStatusProperty, "/status/<path:route>") labthing.add_view(views.SettingsProperty, f"/settings") labthing.add_view(views.NestedSettingsProperty, "/settings/<path:route>") labthing.add_view(views.StatusProperty, "/status") labthing.add_view(views.NestedStatusProperty, "/status/<path:route>") # Attach streams resources labthing.add_resource(views.MjpegStream, f"/streams/mjpeg") labthing.register_property(views.MjpegStream) labthing.add_resource(views.SnapshotStream, f"/streams/snapshot") labthing.register_property(views.SnapshotStream) labthing.add_view(views.MjpegStream, f"/streams/mjpeg") labthing.add_view(views.SnapshotStream, f"/streams/snapshot") # Attach microscope action resources for name, action in views.enabled_root_actions().items(): view_class = action["view_class"] rule = action["rule"] labthing.add_resource(view_class, f"/actions{rule}") labthing.register_action(view_class) labthing.add_view(view_class, f"/actions{rule}") @app.route("/routes") Loading
openflexure_microscope/api/default_extensions/autofocus.py +6 −4 Original line number Diff line number Diff line from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.extensions import BaseExtension from openflexure_microscope.common.flask_labthings.resource import Resource from openflexure_microscope.common.flask_labthings.decorators import ( ThingAction, ThingProperty, ) from openflexure_microscope.devel import JsonResponse, request, jsonify, taskify, abort from openflexure_microscope.utilities import set_properties Loading Loading @@ -298,6 +302,7 @@ class MeasureSharpnessAPI(Resource): return jsonify({"sharpness": measure_sharpness(microscope)}) @ThingAction class AutofocusAPI(Resource): """ Run a standard autofocus Loading @@ -324,6 +329,7 @@ class AutofocusAPI(Resource): abort(503, "No stage connected. Unable to autofocus.") @ThingAction class FastAutofocusAPI(Resource): """ Run a fast autofocus Loading Loading @@ -359,9 +365,5 @@ autofocus_extension_v2.add_method(fast_autofocus, "fast_autofocus") autofocus_extension_v2.add_method(autofocus, "autofocus") autofocus_extension_v2.add_view(MeasureSharpnessAPI, "/measure_sharpness") autofocus_extension_v2.add_view(AutofocusAPI, "/autofocus") autofocus_extension_v2.register_action(AutofocusAPI) autofocus_extension_v2.add_view(FastAutofocusAPI, "/fast_autofocus") autofocus_extension_v2.register_action(FastAutofocusAPI)
openflexure_microscope/api/default_extensions/scan.py +2 −2 Original line number Diff line number Diff line Loading @@ -12,8 +12,8 @@ from openflexure_microscope.common.flask_labthings.find import ( from openflexure_microscope.common.flask_labthings.extensions import BaseExtension from openflexure_microscope.common.flask_labthings.decorators import ( marshal_task, marshal_with, use_args, ThingAction, ) from openflexure_microscope.common.flask_labthings import fields Loading Loading @@ -340,6 +340,7 @@ def stack( ### Web views @ThingAction class TileScanAPI(Resource): @use_args( { Loading Loading @@ -398,4 +399,3 @@ class TileScanAPI(Resource): scan_extension_v2 = BaseExtension("scan") scan_extension_v2.add_view(TileScanAPI, "/tile") scan_extension_v2.register_action(TileScanAPI)
openflexure_microscope/api/default_extensions/zip_builder.py +6 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,10 @@ import logging from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.resource import Resource from openflexure_microscope.common.flask_labthings.extensions import BaseExtension from openflexure_microscope.common.flask_labthings.decorators import ( ThingAction, ThingProperty, ) class ZipManager: Loading Loading @@ -91,6 +95,7 @@ class ZipManager: default_zip_manager = ZipManager() @ThingAction class ZipBuilderAPIView(Resource): def post(self): Loading @@ -103,6 +108,7 @@ class ZipBuilderAPIView(Resource): return jsonify(task.state), 201 @ThingProperty class ZipListAPIView(Resource): def get(self): return jsonify(default_zip_manager.session_zips) Loading Loading @@ -146,4 +152,3 @@ zip_extension_v2.add_view(ZipGetterAPIView, "/get/<string:session_id>") zip_extension_v2.add_view(ZipListAPIView, "/get") zip_extension_v2.add_view(ZipBuilderAPIView, "/build") zip_extension_v2.register_action(ZipBuilderAPIView)
openflexure_microscope/api/example_extensions/ev_gui.py +6 −0 Original line number Diff line number Diff line from openflexure_microscope.common.flask_labthings.resource import Resource from openflexure_microscope.common.flask_labthings.extensions import BaseExtension from openflexure_microscope.common.flask_labthings.decorators import ( ThingAction, ThingProperty, ) from openflexure_microscope.api.utilities.gui import expand_routes Loading Loading @@ -72,6 +76,7 @@ static_form = { } @ThingProperty class TestAPIView(Resource): def get(self): global val_int Loading @@ -79,6 +84,7 @@ class TestAPIView(Resource): return jsonify({"val": True}) @ThingAction class TestDoAPIView(Resource): def post(self): global val_int Loading