2018-08-07 14:02:46 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-08-10 09:08:58 +00:00
|
|
|
from datetime import datetime, timedelta
|
|
|
|
import subprocess
|
|
|
|
|
2018-08-07 14:02:46 +00:00
|
|
|
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
|
2019-04-12 08:01:49 +00:00
|
|
|
try:
|
|
|
|
u = User.objects.get(username='subtitles')
|
|
|
|
except User.DoesNotExist:
|
|
|
|
print('subtitles user does not exist, unable to move subtitles')
|
|
|
|
return
|
2018-08-07 14:02:46 +00:00
|
|
|
annotation.models.Annotation.objects.filter(layer='subtitles').exclude(user=u).update(user=u)
|
2018-08-10 09:08:58 +00:00
|
|
|
|
2019-04-12 08:01:49 +00:00
|
|
|
@periodic_task(run_every=timedelta(hours=1), queue='encoding')
|
|
|
|
def update_ontology(**kwargs):
|
|
|
|
import annotation.models
|
2018-08-10 09:08:58 +00:00
|
|
|
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
|
|
|
|
|
2018-11-15 15:31:46 +00:00
|
|
|
@periodic_task(run_every=timedelta(hours=12), queue='encoding')
|
|
|
|
def render_edits(**kwargs):
|
|
|
|
path = '/home/pandora/pandora_render/render_public_edits.py'
|
2018-12-14 19:04:38 +00:00
|
|
|
if os.path.exists(path):
|
2018-11-15 15:31:46 +00:00
|
|
|
try:
|
|
|
|
subprocess.call([path])
|
|
|
|
except:
|
|
|
|
pass
|