Commit ab6fa9f0 authored by jtc42's avatar jtc42
Browse files

Blackened

parent 6be8b004
Loading
Loading
Loading
Loading
+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

@@ -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):
    """
+3 −1
Original line number Diff line number Diff line
@@ -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()
+4 −10
Original line number Diff line number Diff line
@@ -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):
@@ -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
+17 −17
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ from . import EXTENSION_NAME

import logging


class LabThing(object):
    def __init__(
        self,
@@ -86,7 +87,6 @@ class LabThing(object):
        self._version = version
        self.spec.version = version


    ### Flask stuff

    def init_app(self, app):
@@ -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")
@@ -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

@@ -334,8 +334,8 @@ class LabThing(object):
                "tasks": {
                    "href": self.url_for(TaskList, _external=True),
                    **description_from_view(TaskList),
                }
            }
                },
            },
        }

        return jsonify(rr)
+1 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ from flask.views import MethodView
class Resource(MethodView):
    """Currently identical to MethodView
    """

    endpoint = None
    methods = ["get", "post", "put", "delete"]

@@ -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