Blame view

src/core/pyros_django/scheduling/tasks.py 1.22 KB
1cffbf1c   Etienne Pallier   moved pyros_djang...
1
from __future__ import absolute_import
b95a693f   Alexis Koralewski   restructuration d...
2
from scheduling.Scheduler import Scheduler
1cffbf1c   Etienne Pallier   moved pyros_djang...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from common.models import *
from utils.JDManipulator import *
from utils.Logger import setupLogger

log = setupLogger("TaskSched", "TaskSched")

#class scheduling(Task):
class scheduling():

    #TODO Remove first parameter (useless) -> maybe both ?
    def run(self, first_schedule=False, alert=False):
        print("In scheduling.run()")
        # AttributeError: 'scheduling' object has no attribute 'request'
        ##task = TaskId.objects.create(task_id=self.request.id, task="scheduling")
        Log.objects.create(agent='Scheduler', message='Start schedule : ' + str(datetime.datetime.now()))
        # This creates a Scheduler (in memory) which creates a Schedule (in DB)
        self.scheduler = Scheduler()
        self.scheduler.setNightLimits(secondsToJulianDate(getNightStart()), secondsToJulianDate(getNightEnd()))
        print("****sched-task: NEW SCHEDULE", self.scheduler.schedule, "*****")
        self.scheduler.makeSchedule()
        print("****sched-task: NEW SCHEDULE", self.scheduler.schedule, "*****")
        Log.objects.create(agent='Scheduler', message='Scheduling finished : ' + str(datetime.datetime.now()))
        ##task.delete()