Refactored adding views, actions, props and components
This commit is contained in:
parent
7715c19305
commit
a4196b6765
10 changed files with 62 additions and 66 deletions
|
|
@ -1,6 +1,10 @@
|
|||
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
|
||||
|
|
@ -298,6 +302,7 @@ class MeasureSharpnessAPI(Resource):
|
|||
return jsonify({"sharpness": measure_sharpness(microscope)})
|
||||
|
||||
|
||||
@ThingAction
|
||||
class AutofocusAPI(Resource):
|
||||
"""
|
||||
Run a standard autofocus
|
||||
|
|
@ -324,6 +329,7 @@ class AutofocusAPI(Resource):
|
|||
abort(503, "No stage connected. Unable to autofocus.")
|
||||
|
||||
|
||||
@ThingAction
|
||||
class FastAutofocusAPI(Resource):
|
||||
"""
|
||||
Run a fast autofocus
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
@ -340,6 +340,7 @@ def stack(
|
|||
### Web views
|
||||
|
||||
|
||||
@ThingAction
|
||||
class TileScanAPI(Resource):
|
||||
@use_args(
|
||||
{
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
@ -91,6 +95,7 @@ class ZipManager:
|
|||
default_zip_manager = ZipManager()
|
||||
|
||||
|
||||
@ThingAction
|
||||
class ZipBuilderAPIView(Resource):
|
||||
def post(self):
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue