Blame view

src/scheduler/tasks.py 1.15 KB
5b5566ab   haribo   added celery
1
from __future__ import absolute_import
5b5566ab   haribo   added celery
2
from celery.task import Task
ddf59dd4   haribo   Remaniement :
3
4
from scheduler.Scheduler import Scheduler
from common.models import *
bca9a283   Jeremy   Reworked the sche...
5
from utils.JDManipulator import *
675fb3d5   Jeremy   Update scheduler ...
6
from utils.Logger import setupLogger
c53a13e0   Jeremy   Updating a lot of...
7

675fb3d5   Jeremy   Update scheduler ...
8
log = setupLogger("TaskSched", "TaskSched")
5b5566ab   haribo   added celery
9

7a79e25b   haribo   Date: 19/05/2016
10
class scheduling(Task):
77816f10   haribo   Workflow implemen...
11

257abe9b   Jeremy   Added comments
12
    #TODO Remove first parameter (useless) -> maybe both ?
eecfb779   haribo   Date: 26/05/2016
13
    def run(self, first_schedule=False, alert=False):
e573c1f1   Etienne Pallier   All unit tests no...
14
        print("In scheduling.run()")
c53a13e0   Jeremy   Updating a lot of...
15
        task = TaskId.objects.create(task_id=self.request.id, task="scheduling")
bca9a283   Jeremy   Reworked the sche...
16
        Log.objects.create(agent='Scheduler', message='Start schedule : ' + str(datetime.datetime.now()))
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
17
        # This creates a Scheduler (in memory) which creates a Schedule (in DB)
77816f10   haribo   Workflow implemen...
18
        self.scheduler = Scheduler()
bca9a283   Jeremy   Reworked the sche...
19
        self.scheduler.setNightLimits(secondsToJulianDate(getNightStart()), secondsToJulianDate(getNightEnd()))
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
20
        print("****sched-task: NEW SCHEDULE", self.scheduler.schedule, "*****")
bca9a283   Jeremy   Reworked the sche...
21
        self.scheduler.makeSchedule()
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
22
        print("****sched-task: NEW SCHEDULE", self.scheduler.schedule, "*****")
c53a13e0   Jeremy   Updating a lot of...
23
24
        Log.objects.create(agent='Scheduler', message='Scheduling finished : ' + str(datetime.datetime.now()))
        task.delete()