Initial 0.7.0 conversion

This commit is contained in:
Joel Collins 2020-06-29 15:24:59 +01:00
parent 3bb870a3a3
commit e6cb9f6b35
11 changed files with 129 additions and 130 deletions

View file

@ -58,7 +58,6 @@ def enabled_root_actions():
return {k: v for k, v in _actions.items() if v["conditions"]}
# @Tag("actions")
class ActionsView(View):
def get(self):
"""

View file

@ -1,19 +1,11 @@
from openflexure_microscope.api.utilities import get_bool, JsonResponse
from labthings.server.view import View, ActionView
from labthings.server.find import find_component
from labthings.server.decorators import (
use_args,
marshal_with,
doc,
tag,
ThingAction,
doc_response,
)
from labthings.server import fields
from openflexure_microscope.utilities import filter_dict
from openflexure_microscope.api.v2.views.captures import capture_schema
from openflexure_microscope.api.v2.views.captures import CaptureSchema
import logging
import io
@ -25,24 +17,23 @@ class CaptureAPI(ActionView):
Create a new image capture.
"""
@use_args(
{
"filename": fields.String(example="MyFileName"),
"temporary": fields.Boolean(
missing=False, description="Delete capture on shutdown"
),
"use_video_port": fields.Boolean(missing=False),
"bayer": fields.Boolean(
missing=False, description="Store raw bayer data in file"
),
"annotations": fields.Dict(missing={}, example={"Client": "SwaggerUI"}),
"tags": fields.List(fields.String, missing=[], example=["docs"]),
"resize": fields.Dict(
missing=None, example={"width": 640, "height": 480}
), # TODO: Validate keys
}
)
@marshal_with(capture_schema)
args = {
"filename": fields.String(example="MyFileName"),
"temporary": fields.Boolean(
missing=False, description="Delete capture on shutdown"
),
"use_video_port": fields.Boolean(missing=False),
"bayer": fields.Boolean(
missing=False, description="Store raw bayer data in file"
),
"annotations": fields.Dict(missing={}, example={"Client": "SwaggerUI"}),
"tags": fields.List(fields.String, missing=[], example=["docs"]),
"resize": fields.Dict(
missing=None, example={"width": 640, "height": 480}
), # TODO: Validate keys
}
schema = CaptureSchema()
def post(self, args):
"""
Create a new capture
@ -78,18 +69,22 @@ class RAMCaptureAPI(ActionView):
Take a non-persistant image capture.
"""
@use_args(
{
"use_video_port": fields.Boolean(missing=True),
"bayer": fields.Boolean(
missing=False, description="Return with raw bayer data"
),
"resize": fields.Dict(
missing=None, example={"width": 640, "height": 480}
), # TODO: Validate keys
args = {
"use_video_port": fields.Boolean(missing=True),
"bayer": fields.Boolean(
missing=False, description="Return with raw bayer data"
),
"resize": fields.Dict(
missing=None, example={"width": 640, "height": 480}
), # TODO: Validate keys
}
responses = {
200: {
"content_type": "image/jpeg"
}
)
@doc_response(200, mimetype="image/jpeg")
}
def post(self, args):
"""
Take a non-persistant image capture.
@ -128,9 +123,8 @@ class GPUPreviewStartAPI(ActionView):
in the format ``[x, y, width, height]``.
"""
@use_args(
{"window": fields.List(fields.Integer, missing=[], example=[0, 0, 640, 480])}
)
args = {"window": fields.List(fields.Integer, missing=[], example=[0, 0, 640, 480])}
def post(self, args):
"""
Start the onboard GPU preview.

View file

@ -1,7 +1,6 @@
from openflexure_microscope.api.utilities import JsonResponse
from labthings.server.view import View, ActionView
from labthings.server.find import find_component
from labthings.server.decorators import use_args, marshal_with, doc, ThingAction
from labthings.server import fields
from openflexure_microscope.utilities import axes_to_array, filter_dict
@ -12,16 +11,15 @@ import logging
class MoveStageAPI(ActionView):
@use_args(
{
"absolute": fields.Boolean(
default=False, example=False, description="Move to an absolute position"
),
"x": fields.Int(default=0, example=100),
"y": fields.Int(default=0, example=100),
"z": fields.Int(default=0, example=20),
}
)
args = {
"absolute": fields.Boolean(
default=False, example=False, description="Move to an absolute position"
),
"x": fields.Int(default=0, example=100),
"y": fields.Int(default=0, example=100),
"z": fields.Int(default=0, example=20),
}
def post(self, args):
"""
Move the microscope stage in x, y, z

View file

@ -3,8 +3,6 @@ import subprocess
import os
from sys import platform
from labthings.server.decorators import ThingAction, doc_response
def is_raspberrypi(raise_on_errors=False):
"""
@ -19,7 +17,6 @@ class ShutdownAPI(ActionView):
Attempt to shutdown the device
"""
@doc_response(201)
def post(self):
"""
Attempt to shutdown the device
@ -31,7 +28,7 @@ class ShutdownAPI(ActionView):
)
out, err = p.communicate()
return {"out": out, "err": err}, 201
return {"out": out, "err": err}
class RebootAPI(ActionView):
@ -39,7 +36,6 @@ class RebootAPI(ActionView):
Attempt to reboot the device
"""
@doc_response(201)
def post(self):
"""
Attempt to reboot the device
@ -51,4 +47,4 @@ class RebootAPI(ActionView):
)
out, err = p.communicate()
return {"out": out, "err": err}, 201
return {"out": out, "err": err}