Moved task routes into base labthing

This commit is contained in:
Joel Collins 2019-12-18 14:56:45 +00:00
parent f2af359b8b
commit 1047257242
21 changed files with 123 additions and 1481 deletions

View file

@ -0,0 +1,5 @@
from .actions import enabled_root_actions
from .captures import *
from .state import *
from .streams import *
from .tasks import *

View file

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

View file

@ -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",
)

View file

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