Blame view

src/observation_manager/tasks.py 815 Bytes
5b5566ab   haribo   added celery
1
2
3
from __future__ import absolute_import

from celery.task import Task
77816f10   haribo   Workflow implemen...
4
from analyzer.tasks import analysis
bb45cd4a   haribo   Date: 25/05/2016
5
from pyrosapp.models import *
5b5566ab   haribo   added celery
6
7

import time
77816f10   haribo   Workflow implemen...
8
9
10
import os

IMAGES_FOLDER = 'simulation_images'
5b5566ab   haribo   added celery
11
12
13

class execute_plan(Task):

77816f10   haribo   Workflow implemen...
14
    def run(self, plan_pk):
bb45cd4a   haribo   Date: 25/05/2016
15
16
#         print("ex plan : ", self.request.id)
        TaskId.objects.filter(task_id=self.request.id).delete()
77816f10   haribo   Workflow implemen...
17
18
19
20
21
22
23
24
25
        message = 'Start plan ' + str(plan_pk) + ' execution'
        Log.objects.create(agent='Observation manager', message=message)
        print("execute_plan : ", plan_pk)
        time.sleep(1)
        with open(os.path.join(IMAGES_FOLDER, str(plan_pk)), 'w'):
            pass
        analysis.delay(plan_pk)
        message = 'Finished plan ' + str(plan_pk) + ' execution'
        Log.objects.create(agent='Observation manager', message=message)