From b1f2be4453e6c58f751cfcd58459c28fc7fe6efc Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Tue, 7 Apr 2015 21:46:41 +0200 Subject: [PATCH] Task: Do not allow starting a Task which has already been started --- tasklib/task.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tasklib/task.py b/tasklib/task.py index 1121988..9af111b 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -421,6 +421,12 @@ class Task(TaskResource): """ pass + class ActiveTask(Exception): + """ + Raised when the operation cannot be performed on the active task. + """ + pass + class InactiveTask(Exception): """ Raised when the operation cannot be performed on an inactive task. @@ -600,6 +606,8 @@ class Task(TaskResource): raise Task.CompletedTask("Cannot start a completed task") elif self.deleted: raise Task.DeletedTask("Deleted task cannot be started") + elif self.active: + raise Task.ActiveTask("Task is already active") self.warrior.execute_command([self['uuid'], 'start']) -- 2.39.2