def addTimedAction(self, time, task, name): """Add a task to be run once, at a specific time.""" handle = self.unregisterTask(name) if not handle: handle = TaskHandler(self, time, 0, task, name) else: handle.reset(time, 0, task, True) self.scheduleTask(handle)
def addTimedAction(self, time, task, name): """ This method is used to add an action to be run once, at a specific time. """ handle = self.unregisterTask(name) if not handle: handle = TaskHandler(self, time, 0, task, name) else: handle.reset(time, 0, task, 1) self.scheduleTask(handle)
def addActionOnDemand(self, task, name): """ This method is used to add a task to the scheduler that will not be scheduled until specifically requested. """ handle = self.unregisterTask(name) if not handle: handle = TaskHandler(self, time(), 0, task, name) else: handle.reset(time(), 0, task, 1) self.setOnDemand(handle)
def addActionOnDemand(self, task, name): """Add a task to be run only on demand. Adds a task to the scheduler that will not be scheduled until specifically requested. """ handle = self.unregisterTask(name) if handle: handle.reset(time(), 0, task, True) else: handle = TaskHandler(self, time(), 0, task, name) handle.setOnDemand() self.setOnDemand(handle)
def addTimedAction(self, time, task, name): """Add a task to be run once, at a specific time.""" handle = self.unregisterTask(name) if handle: handle.reset(time, 0, task, True) else: handle = TaskHandler(self, time, 0, task, name) self.scheduleTask(handle)
def addPeriodicAction(self, start, period, task, name): """ This method is used to add an action to be run at a specific initial time, and every period thereafter. The scheduler will not reschedule a task until the last scheduled instance of the task has completed. If a task with the given name is already registered with the scheduler, that task will be removed from the scheduling queue and registered anew as a periodic task. """ handle = self.unregisterTask(name) if not handle: handle = TaskHandler(self, start, period, task, name) else: handle.reset(start, period, task, 1) self.scheduleTask(handle)
def addPeriodicAction(self, start, period, task, name): """Add a task to be run periodically. Adds an action to be run at a specific initial time, and every period thereafter. The scheduler will not reschedule a task until the last scheduled instance of the task has completed. If a task with the given name is already registered with the scheduler, that task will be removed from the scheduling queue and registered anew as a periodic task. """ handle = self.unregisterTask(name) if not handle: handle = TaskHandler(self, start, period, task, name) else: handle.reset(start, period, task, True) self.scheduleTask(handle)
from flask import Blueprint from flask import render_template from flask import request from TaskHandler import TaskHandler from TodoHandler import TodoHandler from TodoTagsHandler import TodoTagsHandler import ResponseHandler import DecodeToken from flask_api import status tasks = Blueprint('tasks', __name__, template_folder='templates') task_handler = TaskHandler() todo_handler = TodoHandler() @tasks.route('/', methods=['GET','POST']) def new_task(): user_id = DecodeToken.get_user_id(request.headers) if user_id is not None: if request.method == 'POST': post_content = request.json response_http_code = task_handler.create(user_id, post_content.get("data")) elif request.method == 'GET': response = task_handler.get_all_tasks_and_todos(user_id) return ResponseHandler.construct_json_response( { "http_code": response.get("http_code"), "data": response.get("data") } ) else: