tasks.py
841 Bytes
from __future__ import absolute_import
from celery.task import Task
from scheduler.Scheduler import Scheduler
from common.models import *
from utils.JDManipulator import *
from utils.Logger import setupLogger
log = setupLogger("TaskSched", "TaskSched")
class scheduling(Task):
def run(self, first_schedule=False, alert=False):
task = TaskId.objects.create(task_id=self.request.id, task="scheduling")
Log.objects.create(agent='Scheduler', message='Start schedule : ' + str(datetime.datetime.now()))
self.scheduler = Scheduler()
self.scheduler.setNightLimits(secondsToJulianDate(getNightStart()), secondsToJulianDate(getNightEnd()))
self.scheduler.makeSchedule()
Log.objects.create(agent='Scheduler', message='Scheduling finished : ' + str(datetime.datetime.now()))
task.delete()