Beispiel #1
0
 def stop_task(cls, name):
     task = Backend('task').find(name)
     if not task.is_running():
         task.status = Task.STOP
         Backend('task').save(task)
         return True
     return False
Beispiel #2
0
    def delete_task(self, name):
        task = Backend('task').find(name)
        if not task:
            return {'status': 'error', 'msg': 'Doesn\'t exist  the task'}

        if not task.is_running():
            Backend('task').delete(task)
            return {'status': 'redirect', 'msg': 'deleted, wait to redirect to /task', 'url': '/task'}
        else:
            return {'status': 'error', 'msg': 'The task is runnig'}
Beispiel #3
0
    def edit_task(self,  name, action, data, event, status):
        try:
            action, data, status = self.process_task_args(action, data, status)
        except TypeError as e:
            return {'msg': str(e), 'status': 'error'}

        task = Backend('task').find(name)
        if not task:
            raise cherrypy.HTTPError(404, 'nof found')

        if not task.is_running():
            task.action = action
            task.status = status
            try:
                task.event = event
            except:
                return {'msg': 'event invalid', 'status': 'error'}
            Backend('task').save(task)
            return {'status': 'info', 'msg': 'saved', }
        else:
            return {'status': 'error', 'msg': 'The task is runnig'}
Beispiel #4
0
 def delete_task(cls, name):
     task = Backend('task').find(name)
     if not task.is_running():
         Backend('task').delete(task)
         return True
     return False