# -*- coding: utf-8 -*- from datetime import datetime, timedelta import subprocess from celery.task import periodic_task @periodic_task(run_every=timedelta(hours=1), queue='encoding') def subtitles_user(**kwargs): import annotation.models from user.models import User u = User.objects.get(username='subtitles') annotation.models.Annotation.objects.filter(layer='subtitles').exclude(user=u).update(user=u) t = datetime.now() - annotation.models.Annotation.objects.all().order_by('-created')[0].created if t < timedelta(hours=1): try: subprocess.call(['/srv/pandora/pandora/cms/ontology/update.sh']) except: pass @periodic_task(run_every=timedelta(hours=12), queue='encoding') def render_edits(**kwargs): path = '/home/pandora/pandora_render/render_public_edits.py' if os.path.exists(path) try: subprocess.call([path]) except: pass