From d7734def143999186a3d77fc440a9336af9b8f6b Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Tue, 11 Feb 2020 15:21:45 +0000 Subject: [PATCH] Renamed tasks dict to fix PYL-W0622 --- labthings/core/tasks/__init__.py | 4 ++-- labthings/core/tasks/pool.py | 2 +- labthings/server/views/tasks.py | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/labthings/core/tasks/__init__.py b/labthings/core/tasks/__init__.py index 282998ca..f9255de8 100644 --- a/labthings/core/tasks/__init__.py +++ b/labthings/core/tasks/__init__.py @@ -1,7 +1,7 @@ __all__ = [ "taskify", "tasks", - "dict", + "dictionary", "states", "current_task", "update_task_progress", @@ -13,7 +13,7 @@ from .pool import ( tasks, - dict, + dictionary, states, current_task, update_task_progress, diff --git a/labthings/core/tasks/pool.py b/labthings/core/tasks/pool.py index 44ac8c66..1c07cd91 100644 --- a/labthings/core/tasks/pool.py +++ b/labthings/core/tasks/pool.py @@ -67,7 +67,7 @@ def tasks(): return DEFAULT_TASK_MASTER.tasks -def dict(): +def dictionary(): """ Dictionary of tasks in default taskmaster Returns: diff --git a/labthings/server/views/tasks.py b/labthings/server/views/tasks.py index 55574af0..04595a04 100644 --- a/labthings/server/views/tasks.py +++ b/labthings/server/views/tasks.py @@ -18,29 +18,29 @@ def get(self): @Tag(["properties", "tasks"]) class TaskView(View): @marshal_with(TaskSchema()) - def get(self, id): + def get(self, task_id): """ Show status of a session task Includes progress and intermediate data. """ - try: - task = tasks.dict()[id] - except KeyError: + + task = tasks.dictionary().get(task_id) + if not task: return abort(404) # 404 Not Found return task @marshal_with(TaskSchema()) - def delete(self, id): + def delete(self, task_id): """ Terminate a running task. If the task is finished, deletes its entry. """ - try: - task = tasks.dict()[id] - except KeyError: + + task = tasks.dictionary().get(task_id) + if not task: return abort(404) # 404 Not Found task.terminate()