Loading openflexure_microscope/api/v2/views/actions/camera.py +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ from openflexure_microscope.common.flask_labthings.decorators import ( doc, doc_response, ) from openflexure_microscope.common.flask_labthings import fields from openflexure_microscope.utilities import filter_dict Loading openflexure_microscope/api/v2/views/state.py +6 −1 Original line number Diff line number Diff line from openflexure_microscope.api.utilities import JsonResponse from openflexure_microscope.utilities import get_by_path, set_by_path, create_from_path from openflexure_microscope.common.labthings_core.utilities import ( get_by_path, set_by_path, create_from_path, ) from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.resource import Resource Loading openflexure_microscope/api/v2/views/streams.py +6 −1 Original line number Diff line number Diff line from openflexure_microscope.api.utilities import gen, JsonResponse from openflexure_microscope.utilities import get_by_path, set_by_path, create_from_path from openflexure_microscope.common.labthings_core.utilities import ( get_by_path, set_by_path, create_from_path, ) from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.resource import Resource Loading openflexure_microscope/common/flask_labthings/decorators.py +4 −26 Original line number Diff line number Diff line Loading @@ -2,8 +2,10 @@ from webargs import flaskparser from functools import wraps, update_wrapper from flask import make_response from .utilities import rupdate from .spec import update_spec from openflexure_microscope.common.labthings_core.utilities import rupdate from openflexure_microscope.common.labthings_core.spec import update_spec from openflexure_microscope.common.labthings_core.decorators import doc, doc_response def unpack(value): Loading Loading @@ -74,27 +76,3 @@ class use_kwargs(use_args): """ kwargs["as_kwargs"] = True use_args.__init__(self, schema, **kwargs) class doc(object): def __init__(self, **kwargs): self.kwargs = kwargs def __call__(self, f): # Pass params to call function attribute for external access update_spec(f, self.kwargs) return f class doc_response(object): def __init__(self, code, description, **kwargs): self.code = code self.description = description self.kwargs = kwargs 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}}} rupdate(f.__apispec__, d) return f openflexure_microscope/common/flask_labthings/extensions.py +10 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,14 @@ import sys import os import glob from openflexure_microscope.common.labthings_core.utilities import get_docstring from openflexure_microscope.utilities import camel_to_snake, snake_to_spine from openflexure_microscope.common.labthings_core.utilities import ( get_docstring, camel_to_snake, snake_to_spine, ) # TODO: Move into core? class BaseExtension: Loading Loading @@ -134,7 +140,7 @@ def find_instances_in_module(module, class_to_find): return objs def find_extensions_in_file(extension_path, module_name="extensions"): def find_extensions_in_file(extension_path: str, module_name="extensions"): logging.debug(f"Loading extensions from {extension_path}") spec = util.spec_from_file_location(module_name, extension_path) Loading @@ -149,7 +155,7 @@ def find_extensions_in_file(extension_path, module_name="extensions"): return find_instances_in_module(mod, BaseExtension) def find_extensions(extension_dir, module_name="extensions"): def find_extensions(extension_dir: str, module_name="extensions"): logging.debug(f"Loading extensions from {extension_dir}") extensions = [] Loading Loading
openflexure_microscope/api/v2/views/actions/camera.py +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ from openflexure_microscope.common.flask_labthings.decorators import ( doc, doc_response, ) from openflexure_microscope.common.flask_labthings import fields from openflexure_microscope.utilities import filter_dict Loading
openflexure_microscope/api/v2/views/state.py +6 −1 Original line number Diff line number Diff line from openflexure_microscope.api.utilities import JsonResponse from openflexure_microscope.utilities import get_by_path, set_by_path, create_from_path from openflexure_microscope.common.labthings_core.utilities import ( get_by_path, set_by_path, create_from_path, ) from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.resource import Resource Loading
openflexure_microscope/api/v2/views/streams.py +6 −1 Original line number Diff line number Diff line from openflexure_microscope.api.utilities import gen, JsonResponse from openflexure_microscope.utilities import get_by_path, set_by_path, create_from_path from openflexure_microscope.common.labthings_core.utilities import ( get_by_path, set_by_path, create_from_path, ) from openflexure_microscope.common.flask_labthings.find import find_device from openflexure_microscope.common.flask_labthings.resource import Resource Loading
openflexure_microscope/common/flask_labthings/decorators.py +4 −26 Original line number Diff line number Diff line Loading @@ -2,8 +2,10 @@ from webargs import flaskparser from functools import wraps, update_wrapper from flask import make_response from .utilities import rupdate from .spec import update_spec from openflexure_microscope.common.labthings_core.utilities import rupdate from openflexure_microscope.common.labthings_core.spec import update_spec from openflexure_microscope.common.labthings_core.decorators import doc, doc_response def unpack(value): Loading Loading @@ -74,27 +76,3 @@ class use_kwargs(use_args): """ kwargs["as_kwargs"] = True use_args.__init__(self, schema, **kwargs) class doc(object): def __init__(self, **kwargs): self.kwargs = kwargs def __call__(self, f): # Pass params to call function attribute for external access update_spec(f, self.kwargs) return f class doc_response(object): def __init__(self, code, description, **kwargs): self.code = code self.description = description self.kwargs = kwargs 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}}} rupdate(f.__apispec__, d) return f
openflexure_microscope/common/flask_labthings/extensions.py +10 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,14 @@ import sys import os import glob from openflexure_microscope.common.labthings_core.utilities import get_docstring from openflexure_microscope.utilities import camel_to_snake, snake_to_spine from openflexure_microscope.common.labthings_core.utilities import ( get_docstring, camel_to_snake, snake_to_spine, ) # TODO: Move into core? class BaseExtension: Loading Loading @@ -134,7 +140,7 @@ def find_instances_in_module(module, class_to_find): return objs def find_extensions_in_file(extension_path, module_name="extensions"): def find_extensions_in_file(extension_path: str, module_name="extensions"): logging.debug(f"Loading extensions from {extension_path}") spec = util.spec_from_file_location(module_name, extension_path) Loading @@ -149,7 +155,7 @@ def find_extensions_in_file(extension_path, module_name="extensions"): return find_instances_in_module(mod, BaseExtension) def find_extensions(extension_dir, module_name="extensions"): def find_extensions(extension_dir: str, module_name="extensions"): logging.debug(f"Loading extensions from {extension_dir}") extensions = [] Loading