Moved task routes into base labthing
This commit is contained in:
parent
f2af359b8b
commit
1047257242
21 changed files with 123 additions and 1481 deletions
5
openflexure_microscope/api/v2/views/__init__.py
Normal file
5
openflexure_microscope/api/v2/views/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from .actions import enabled_root_actions
|
||||
from .captures import *
|
||||
from .state import *
|
||||
from .streams import *
|
||||
from .tasks import *
|
||||
|
|
@ -49,17 +49,6 @@ _actions = {
|
|||
}
|
||||
|
||||
|
||||
def enabled_actions():
|
||||
def enabled_root_actions():
|
||||
global _actions
|
||||
return {k: v for k, v in _actions.items() if v["conditions"]}
|
||||
|
||||
|
||||
def add_actions_to_labthing(labthing, prefix=""):
|
||||
"""
|
||||
Add all capture resources to a labthing
|
||||
"""
|
||||
for name, action in enabled_actions().items():
|
||||
view_class = action["view_class"]
|
||||
rule = action["rule"]
|
||||
labthing.add_resource(view_class, f"{prefix}/actions{rule}")
|
||||
labthing.register_action(view_class)
|
||||
|
|
|
|||
|
|
@ -70,25 +70,3 @@ class NestedStatusProperty(Resource):
|
|||
|
||||
return jsonify(value)
|
||||
|
||||
|
||||
def add_states_to_labthing(labthing, prefix=""):
|
||||
"""
|
||||
Add all settings and status resources to a labthing
|
||||
"""
|
||||
labthing.add_resource(
|
||||
SettingsProperty, f"{prefix}/settings", endpoint="SettingsProperty"
|
||||
)
|
||||
labthing.register_property(SettingsProperty)
|
||||
labthing.add_resource(
|
||||
NestedSettingsProperty,
|
||||
f"{prefix}/settings/<path:route>",
|
||||
endpoint="NestedSettingsProperty",
|
||||
)
|
||||
labthing.add_resource(StatusProperty, f"{prefix}/status", endpoint="StatusProperty")
|
||||
labthing.register_property(StatusProperty)
|
||||
labthing.add_resource(
|
||||
NestedStatusProperty,
|
||||
f"{prefix}/status/<path:route>",
|
||||
endpoint="NestedStatusProperty",
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -59,13 +59,3 @@ class TaskResource(Resource):
|
|||
task.terminate()
|
||||
|
||||
return jsonify(task.state)
|
||||
|
||||
|
||||
def add_tasks_to_labthing(labthing, prefix=""):
|
||||
"""
|
||||
Add all settings and status resources to a labthing
|
||||
"""
|
||||
labthing.add_resource(TaskList, f"{prefix}/tasks", endpoint="TasksProperty")
|
||||
labthing.register_property(TaskList)
|
||||
labthing.add_resource(TaskResource, f"{prefix}/tasks/<id>", endpoint="TaskResource")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue