Removed old tasks view
This commit is contained in:
parent
1047257242
commit
5a0188abd3
2 changed files with 0 additions and 62 deletions
|
|
@ -2,4 +2,3 @@ from .actions import enabled_root_actions
|
|||
from .captures import *
|
||||
from .state import *
|
||||
from .streams import *
|
||||
from .tasks import *
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
import logging
|
||||
from flask import abort, request, redirect, url_for, send_file, jsonify
|
||||
|
||||
from openflexure_microscope.api.utilities import get_bool, JsonResponse
|
||||
|
||||
from openflexure_microscope.common.labthings.schema import Schema
|
||||
from openflexure_microscope.common.labthings import fields
|
||||
from openflexure_microscope.common.labthings.resource import Resource
|
||||
|
||||
from openflexure_microscope.common import tasks
|
||||
|
||||
|
||||
class TaskSchema(Schema):
|
||||
_ID = fields.String(data_key="id")
|
||||
target_string = fields.String(data_key="function")
|
||||
_status = fields.String(data_key="status")
|
||||
progress = fields.String()
|
||||
data = fields.Raw()
|
||||
_return_value = fields.Raw(data_key="return")
|
||||
_start_time = fields.String(data_key="start_time")
|
||||
_end_time = fields.String(data_key="end_time")
|
||||
|
||||
# TODO: Add HTTP methods
|
||||
links = fields.Hyperlinks(
|
||||
{
|
||||
"self": {
|
||||
"href": fields.AbsoluteUrlFor("TaskResource", id="<id>"),
|
||||
"mimetype": "application/json",
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
task_schema = TaskSchema()
|
||||
task_list_schema = TaskSchema(many=True)
|
||||
|
||||
|
||||
class TaskList(Resource):
|
||||
def get(self):
|
||||
return task_list_schema.jsonify(tasks.tasks())
|
||||
|
||||
|
||||
class TaskResource(Resource):
|
||||
def get(self, id):
|
||||
try:
|
||||
task = tasks.dict()[id]
|
||||
except KeyError:
|
||||
return abort(404) # 404 Not Found
|
||||
|
||||
# Return task state
|
||||
return jsonify(task)
|
||||
|
||||
def delete(self, id):
|
||||
try:
|
||||
task = tasks.dict()[id]
|
||||
except KeyError:
|
||||
return abort(404) # 404 Not Found
|
||||
|
||||
task.terminate()
|
||||
|
||||
return jsonify(task.state)
|
||||
Loading…
Add table
Add a link
Reference in a new issue