Commit 9b387985 authored by Joel Collins's avatar Joel Collins
Browse files

Use more docstrings as descriptions

parent d3f2807b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
import logging
from werkzeug.exceptions import BadRequest
from flask import url_for
from flask import url_for, Blueprint

def blueprint_for_module(module_name, api_ver=2, suffix=""):
    return Blueprint(blueprint_name_for_module(module_name, api_ver=api_ver, suffix=suffix), module_name)

def blueprint_name_for_module(module_name, api_ver=2, suffix=""):
    bp_name = module_name.split('.')[-1]
    return f"v{api_ver}_{bp_name}_blueprint{suffix}"

class JsonResponse:
    def __init__(self, request):
+9 −4
Original line number Diff line number Diff line
"""
Top-level representation of enabled actions
"""

from flask import Blueprint, url_for, jsonify
from sys import platform

from openflexure_microscope.utilities import get_docstring
from openflexure_microscope.api.utilities import blueprint_for_module
from openflexure_microscope.utilities import get_docstring, description_from_view
from openflexure_microscope.api.views import MicroscopeView

from . import camera, stage, system

# TODO: Could allowed methods be calculated automatically by looking at what methods exist?
_actions = {
    "capture": {
        "rule": "/camera/capture/",
@@ -53,11 +57,12 @@ def actions_representation():
    for name, action in enabled_actions().items():
        d = {
            "links": {"self": url_for(f".{name}")},
            "description": get_docstring(action["view_class"]),
            "rule": action["rule"],
            "view_class": str(action["view_class"]),
        }

        d.update(description_from_view(action["view_class"]))

        actions[name] = d

    return actions
@@ -69,7 +74,7 @@ class ActionsAPI(MicroscopeView):
def construct_blueprint(microscope_obj):
    global _actions

    blueprint = Blueprint("v2_actions_blueprint", __name__)
    blueprint = blueprint_for_module(__name__)

    # For each enabled action route defined in our dictionary above
    for name, action in enabled_actions().items():
+0 −9
Original line number Diff line number Diff line
@@ -9,9 +9,6 @@ from flask import jsonify, request, abort, url_for, redirect, send_file
class CaptureAPI(MicroscopeView):
    """
    Create a new image capture. 
    
    Allowed methods: 
        POST
    """
    def post(self):
        """
@@ -109,9 +106,6 @@ class CaptureAPI(MicroscopeView):
class GPUPreviewStartAPI(MicroscopeView):
    """
    Start the onboard GPU preview.
    
    Allowed methods: 
        POST
    """
    def post(self, operation):
        """
@@ -157,9 +151,6 @@ class GPUPreviewStartAPI(MicroscopeView):
class GPUPreviewStopAPI(MicroscopeView):
    """
    Stop the onboard GPU preview.
    
    Allowed methods: 
        POST
    """
    def post(self, operation):
        """
+0 −3
Original line number Diff line number Diff line
@@ -10,9 +10,6 @@ import logging
class MoveStageAPI(MicroscopeView):
    """
    Handle stage movements. 
    
    Allowed methods: 
        POST
    """
    def post(self):
        """
+0 −6
Original line number Diff line number Diff line
@@ -6,9 +6,6 @@ import subprocess
class ShutdownAPI(MicroscopeView):
    """
    Attempt to shutdown the device 
    
    Allowed methods: 
        POST
    """
    def post(self):
        """
@@ -25,9 +22,6 @@ class ShutdownAPI(MicroscopeView):
class RebootAPI(MicroscopeView):
    """
    Attempt to reboot the device 
    
    Allowed methods: 
        POST
    """
    def post(self):
        """
Loading