Blame view

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

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

5e45ba9f   Etienne Pallier   Bye Bye Celery (f...
9
10
#class scheduling(Task):
class scheduling():
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()")
de992b50   Etienne Pallier   NO MORE CELERY + ...
15
16
        # AttributeError: 'scheduling' object has no attribute 'request'
        ##task = TaskId.objects.create(task_id=self.request.id, task="scheduling")
bca9a283   Jeremy   Reworked the sche...
17
        Log.objects.create(agent='Scheduler', message='Start schedule : ' + str(datetime.datetime.now()))
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
18
        # This creates a Scheduler (in memory) which creates a Schedule (in DB)
77816f10   haribo   Workflow implemen...
19
        self.scheduler = Scheduler()
bca9a283   Jeremy   Reworked the sche...
20
        self.scheduler.setNightLimits(secondsToJulianDate(getNightStart()), secondsToJulianDate(getNightEnd()))
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
21
        print("****sched-task: NEW SCHEDULE", self.scheduler.schedule, "*****")
bca9a283   Jeremy   Reworked the sche...
22
        self.scheduler.makeSchedule()
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
23
        print("****sched-task: NEW SCHEDULE", self.scheduler.schedule, "*****")
c53a13e0   Jeremy   Updating a lot of...
24
        Log.objects.create(agent='Scheduler', message='Scheduling finished : ' + str(datetime.datetime.now()))
de992b50   Etienne Pallier   NO MORE CELERY + ...
25
        ##task.delete()