Blame view

src/majordome/TaskManager.py 1.6 KB
ddf59dd4   haribo   Remaniement :
1
from common.models import *
bb45cd4a   haribo   Date: 25/05/2016
2

9774228b   haribo   Date: 22/06/2016
3
import time
bb0fbab1   haribo   Fini de mettre la...
4
from devices import Telescope, CameraVIS, CameraNIR
bb45cd4a   haribo   Date: 25/05/2016
5

9774228b   haribo   Date: 22/06/2016
6
def delete_pending_tasks(task_names, terminate=False):
bb45cd4a   haribo   Date: 25/05/2016
7
8
9
10
11
12
    '''
        Deletes the pending tasks given in task_names, getting their ids in DB.
        Removes them from db.
        :param task_names: array of tasks names to delete 
    '''

5e45ba9f   Etienne Pallier   Bye Bye Celery (f...
13
    #TODO : il faudra aller plus loin, et dire aux instruments de s'arrĂȘter
9774228b   haribo   Date: 22/06/2016
14

bb45cd4a   haribo   Date: 25/05/2016
15
16
17
18
    for task_name in task_names:
        tasks = TaskId.objects.filter(task=task_name)
        for task in tasks:
            print("je revoke : ", task.task_id)
5e45ba9f   Etienne Pallier   Bye Bye Celery (f...
19
20
            #TODO:
            ###revoke(task.task_id, terminate=terminate)
9774228b   haribo   Date: 22/06/2016
21
22
23
24
25
26
27
28
29
30
31
32
33
            task.delete()

        """ The sleep is in case of sequence stopping :
            if it was creating a plan_exec, the creation must be finished before we try to delete it """
        time.sleep(1)

def delete_pending_routine():
    '''
        It is called in case of a routine registered
        It deletes the pending execute_sequence
    '''

    delete_pending_tasks(["execute_sequence"], terminate=False)
ddf59dd4   haribo   Remaniement :
34
    tel = Telescope.TelescopeController()
00fa2456   haribo   Debug adaption code
35
    tel.do("ABORT")
9774228b   haribo   Date: 22/06/2016
36
37
38
39
40
41
42
43
44


def delete_pending_alert():
    '''
        It is called in case of an alert registered
        It deletes the pending execute_sequence, and the pending + executing plans
    '''

    delete_pending_tasks(["execute_sequence"], terminate=False)
00fa2456   haribo   Debug adaption code
45
46
    delete_pending_tasks(["execute_plan"], terminate=False)

ddf59dd4   haribo   Remaniement :
47
    tel = Telescope.TelescopeController()
bb0fbab1   haribo   Fini de mettre la...
48
49
    VIScam = CameraVIS.VISCameraController()
    NIRcam = CameraNIR.NIRCameraController()
00fa2456   haribo   Debug adaption code
50
51
52
    tel.do("ABORT")
    VIScam.do("ABORT")
    NIRcam.do("ABORT")