Blame view

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

from celery.task import Task
77816f10   haribo   Workflow implemen...
4
5
from analyzer.tasks import analysis
from pyrosapp.models import Log
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
15
16
17
18
19
20
21
22
23
24
    def run(self, plan_pk):
        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)