Loading openflexure_microscope/api/v2/views/actions/camera.py +7 −1 Original line number Diff line number Diff line from openflexure_microscope.api.utilities import get_bool, JsonResponse from openflexure_microscope.common.flask_labthings.resource import Resource from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.decorators import use_args, marshal_with, doc, doc_response from openflexure_microscope.common.flask_labthings.decorators import ( use_args, marshal_with, doc, doc_response, ) from openflexure_microscope.common.flask_labthings import fields from openflexure_microscope.utilities import filter_dict Loading @@ -10,6 +15,7 @@ from openflexure_microscope.api.v2.views.captures import capture_schema import logging from flask import jsonify, request, abort, url_for, redirect, send_file @doc(tags=["actions"]) class CaptureAPI(Resource): """ Loading openflexure_microscope/api/v2/views/captures.py +3 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ from marshmallow import pre_dump class CaptureSchema(Schema): id = fields.String() file = fields.String(data_key="path", description="Path of file on microscope device") file = fields.String( data_key="path", description="Path of file on microscope device" ) exists = fields.Bool(data_key="available") filename = fields.String() metadata = fields.Dict() Loading openflexure_microscope/common/flask_labthings/decorators.py +4 −10 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ from flask import make_response from .utilities import rupdate from .spec import update_spec def unpack(value): """Return a three tuple of data, code, and headers""" if not isinstance(value, tuple): Loading Loading @@ -93,14 +94,7 @@ class doc_response(object): def __call__(self, f): # Pass params to call function attribute for external access f.__apispec__ = f.__dict__.get('__apispec__', {}) d = { "responses": { self.code: { "description": self.description, **self.kwargs } } } f.__apispec__ = f.__dict__.get("__apispec__", {}) d = {"responses": {self.code: {"description": self.description, **self.kwargs}}} rupdate(f.__apispec__, d) return f openflexure_microscope/common/flask_labthings/labthing.py +17 −17 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ from . import EXTENSION_NAME import logging class LabThing(object): def __init__( self, Loading Loading @@ -86,7 +87,6 @@ class LabThing(object): self._version = version self.spec.version = version ### Flask stuff def init_app(self, app): Loading Loading @@ -117,7 +117,9 @@ class LabThing(object): # Add thing description self.app.add_url_rule(self._complete_url("/td", ""), "td", self.td) # Add swagger spec self.app.add_url_rule(self._complete_url("/swagger", ""), "swagger", self.swagger) self.app.add_url_rule( self._complete_url("/swagger", ""), "swagger", self.swagger ) # Add plugin overview self.add_resource(PluginListResource, "/plugins") Loading Loading @@ -261,9 +263,7 @@ class LabThing(object): # Add the url to the application or blueprint app.add_url_rule(rule, view_func=resource_func, **kwargs) # Add the resource to our API spec self.spec.path( **view2path(rule, resource, self.spec) ) self.spec.path(**view2path(rule, resource, self.spec)) ### Utilities Loading Loading @@ -334,8 +334,8 @@ class LabThing(object): "tasks": { "href": self.url_for(TaskList, _external=True), **description_from_view(TaskList), } } }, }, } return jsonify(rr) Loading openflexure_microscope/common/flask_labthings/resource.py +1 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ from flask.views import MethodView class Resource(MethodView): """Currently identical to MethodView """ endpoint = None methods = ["get", "post", "put", "delete"] Loading @@ -15,7 +16,6 @@ class Resource(MethodView): if hasattr(self, "__apispec__"): docs.update(self.__apispec__) for meth in Resource.methods: if hasattr(self, meth) and hasattr(getattr(self, meth), "__apispec__"): docs["operations"][meth] = {} Loading Loading
openflexure_microscope/api/v2/views/actions/camera.py +7 −1 Original line number Diff line number Diff line from openflexure_microscope.api.utilities import get_bool, JsonResponse from openflexure_microscope.common.flask_labthings.resource import Resource from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.decorators import use_args, marshal_with, doc, doc_response from openflexure_microscope.common.flask_labthings.decorators import ( use_args, marshal_with, doc, doc_response, ) from openflexure_microscope.common.flask_labthings import fields from openflexure_microscope.utilities import filter_dict Loading @@ -10,6 +15,7 @@ from openflexure_microscope.api.v2.views.captures import capture_schema import logging from flask import jsonify, request, abort, url_for, redirect, send_file @doc(tags=["actions"]) class CaptureAPI(Resource): """ Loading
openflexure_microscope/api/v2/views/captures.py +3 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ from marshmallow import pre_dump class CaptureSchema(Schema): id = fields.String() file = fields.String(data_key="path", description="Path of file on microscope device") file = fields.String( data_key="path", description="Path of file on microscope device" ) exists = fields.Bool(data_key="available") filename = fields.String() metadata = fields.Dict() Loading
openflexure_microscope/common/flask_labthings/decorators.py +4 −10 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ from flask import make_response from .utilities import rupdate from .spec import update_spec def unpack(value): """Return a three tuple of data, code, and headers""" if not isinstance(value, tuple): Loading Loading @@ -93,14 +94,7 @@ class doc_response(object): def __call__(self, f): # Pass params to call function attribute for external access f.__apispec__ = f.__dict__.get('__apispec__', {}) d = { "responses": { self.code: { "description": self.description, **self.kwargs } } } f.__apispec__ = f.__dict__.get("__apispec__", {}) d = {"responses": {self.code: {"description": self.description, **self.kwargs}}} rupdate(f.__apispec__, d) return f
openflexure_microscope/common/flask_labthings/labthing.py +17 −17 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ from . import EXTENSION_NAME import logging class LabThing(object): def __init__( self, Loading Loading @@ -86,7 +87,6 @@ class LabThing(object): self._version = version self.spec.version = version ### Flask stuff def init_app(self, app): Loading Loading @@ -117,7 +117,9 @@ class LabThing(object): # Add thing description self.app.add_url_rule(self._complete_url("/td", ""), "td", self.td) # Add swagger spec self.app.add_url_rule(self._complete_url("/swagger", ""), "swagger", self.swagger) self.app.add_url_rule( self._complete_url("/swagger", ""), "swagger", self.swagger ) # Add plugin overview self.add_resource(PluginListResource, "/plugins") Loading Loading @@ -261,9 +263,7 @@ class LabThing(object): # Add the url to the application or blueprint app.add_url_rule(rule, view_func=resource_func, **kwargs) # Add the resource to our API spec self.spec.path( **view2path(rule, resource, self.spec) ) self.spec.path(**view2path(rule, resource, self.spec)) ### Utilities Loading Loading @@ -334,8 +334,8 @@ class LabThing(object): "tasks": { "href": self.url_for(TaskList, _external=True), **description_from_view(TaskList), } } }, }, } return jsonify(rr) Loading
openflexure_microscope/common/flask_labthings/resource.py +1 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ from flask.views import MethodView class Resource(MethodView): """Currently identical to MethodView """ endpoint = None methods = ["get", "post", "put", "delete"] Loading @@ -15,7 +16,6 @@ class Resource(MethodView): if hasattr(self, "__apispec__"): docs.update(self.__apispec__) for meth in Resource.methods: if hasattr(self, meth) and hasattr(getattr(self, meth), "__apispec__"): docs["operations"][meth] = {} Loading