Code formatting

This commit is contained in:
Joel Collins 2020-10-13 15:02:19 +01:00
parent 0234b20ce3
commit 2bfb988460
60 changed files with 392 additions and 396 deletions

View file

@ -1,5 +1,5 @@
from labthings.extensions import BaseExtension
from labthings import find_component
from labthings.extensions import BaseExtension
def identify():

View file

@ -1,5 +1,5 @@
from labthings.extensions import BaseExtension
from labthings import find_component
from labthings.extensions import BaseExtension
# Create the extension class

View file

@ -1,5 +1,5 @@
from labthings import fields, find_component
from labthings.extensions import BaseExtension
from labthings import find_component, fields
from labthings.views import View
## Extension methods
@ -41,7 +41,7 @@ class ExampleIdentifyView(View):
class ExampleRenameView(View):
# Expect a request parameter called "name", which is a string.
# Expect a request parameter called "name", which is a string.
# Passed to the argument "args".
args = fields.String(required=True, example="My Example Microscope")

View file

@ -1,5 +1,5 @@
from labthings import Schema, fields, find_component
from labthings.extensions import BaseExtension
from labthings import find_component, Schema, fields
from labthings.views import View
## Extension methods
@ -26,6 +26,7 @@ def rename(microscope, new_name):
## Extension views
class ExampleIdentifyView(View):
# Format our returned object using MicroscopeIdentifySchema
schema = MicroscopeIdentifySchema()

View file

@ -1,6 +1,6 @@
from labthings import Schema, fields, find_component
from labthings.extensions import BaseExtension
from labthings import find_component, Schema, fields
from labthings.views import View, PropertyView
from labthings.views import PropertyView, View
## Extension methods

View file

@ -1,9 +1,9 @@
from labthings.extensions import BaseExtension
from labthings import find_component, Schema, fields
from labthings.views import View, ActionView, PropertyView
import io # Used in our capture action
from flask import send_file # Used to send images from our server
import io # Used in our capture action
from labthings import Schema, fields, find_component
from labthings.extensions import BaseExtension
from labthings.views import ActionView, PropertyView, View
## Extension methods
@ -46,7 +46,6 @@ class ExampleIdentifyView(PropertyView):
return microscope
# We can use a single schema as the input and output will be formatted identically
# Eg. We always expect a "name" string argument, and always return a "name" string attribute
class ExampleRenameView(PropertyView):
@ -83,13 +82,12 @@ class QuickCaptureAPI(ActionView):
"""
Take an image capture and return it without saving
"""
# Expect a "use_video_port" boolean, which defaults to True if none is given
args = {"use_video_port": fields.Boolean(missing=True)}
# Our success response (200) returns an image (image/jpeg mimetype)
responses = {
200: {"content_type": "image/jpeg"}
}
responses = {200: {"content_type": "image/jpeg"}}
def post(self, args):
"""

View file

@ -1,15 +1,20 @@
from labthings.extensions import BaseExtension
from labthings import find_component, Schema, fields, update_action_progress, current_action
from labthings.views import View, ActionView, PropertyView
from flask import send_file # Used to send images from our server
import io # Used in our capture action
import time # Used in our timelapse function
from flask import send_file # Used to send images from our server
from labthings import (
Schema,
current_action,
fields,
find_component,
update_action_progress,
)
from labthings.extensions import BaseExtension
from labthings.views import ActionView, PropertyView, View
# Used in our timelapse function
from openflexure_microscope.captures.capture_manager import generate_basename
## Extension methods
@ -59,6 +64,7 @@ class TimelapseAPI(ActionView):
"""
Take a series of images in a timelapse
"""
args = {
"n_images": fields.Integer(
required=True, example=5, description="Number of images"
@ -73,9 +79,7 @@ class TimelapseAPI(ActionView):
microscope = find_component("org.openflexure.microscope")
# Start "timelapse"
return timelapse(
microscope, args.get("n_images"), args.get("t_between")
)
return timelapse(microscope, args.get("n_images"), args.get("t_between"))
## Create extension

View file

@ -1,17 +1,23 @@
from labthings.extensions import BaseExtension
from labthings import find_component, Schema, fields, update_action_progress, current_action
from labthings.views import View, ActionView, PropertyView
from flask import send_file # Used to send images from our server
import io # Used in our capture action
import time # Used in our timelapse function
# Used in our timelapse function
from openflexure_microscope.captures.capture_manager import generate_basename
from flask import send_file # Used to send images from our server
from labthings import (
Schema,
current_action,
fields,
find_component,
update_action_progress,
)
from labthings.extensions import BaseExtension
from labthings.views import ActionView, PropertyView, View
# Used to convert our GUI dictionary into a complete eV extension GUI
from openflexure_microscope.api.utilities.gui import build_gui
# Used in our timelapse function
from openflexure_microscope.captures.capture_manager import generate_basename
## Extension methods
@ -61,6 +67,7 @@ class TimelapseAPI(ActionView):
"""
Take a series of images in a timelapse, running as a background task
"""
args = {
"n_images": fields.Integer(
required=True, example=5, description="Number of images"
@ -75,9 +82,7 @@ class TimelapseAPI(ActionView):
microscope = find_component("org.openflexure.microscope")
# Create and start "timelapse", running in a background task
return timelapse(
microscope, args.get("n_images"), args.get("t_between")
)
return timelapse(microscope, args.get("n_images"), args.get("t_between"))
## Extension GUI (OpenFlexure eV)