tasks.py 714 Bytes
from __future__ import absolute_import

from celery.task import Task
from analyzer.tasks import analysis
from pyrosapp.models import Log

import time
import os

IMAGES_FOLDER = 'simulation_images'

class execute_plan(Task):

    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)