From 4c1dc2afe2517a9f821c837af5b2f9d7decb14f5 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 28 Jan 2012 11:22:51 +0100 Subject: [PATCH] fix import script --- .../management/commands/import_streams.py | 28 ++----------------- pandora/archive/tasks.py | 25 ++++++++++++++++- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/pandora/archive/management/commands/import_streams.py b/pandora/archive/management/commands/import_streams.py index 92c909036..573177f52 100644 --- a/pandora/archive/management/commands/import_streams.py +++ b/pandora/archive/management/commands/import_streams.py @@ -3,33 +3,11 @@ from django.core.management.base import BaseCommand from django.conf import settings import os -from glob import glob -from celery.task import task +import monkey_patch.models +from ... import models +from ...tasks import update_stream -from ... import models, extract - - -@task(queue="encoding") -def update_stream(id): - s = models.Stream.objects.get(pk=id) - if not glob("%s*"%s.timeline_prefix): - s.make_timeline() - if not s.color: - s.cuts = tuple(extract.cuts(s.timeline_prefix)) - s.color = tuple(extract.average_color(s.timeline_prefix)) - s.save() - - s.file.selected = True - s.file.save() - s.file.item.update_timeline() - #make sure all derivatives exist - s.extract_derivatives() - - #update clips - for c in s.file.item.clips.all(): - c.update_calculated_values() - c.save() class Command(BaseCommand): """ diff --git a/pandora/archive/tasks.py b/pandora/archive/tasks.py index c31260da6..8bacd84a6 100644 --- a/pandora/archive/tasks.py +++ b/pandora/archive/tasks.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 +from glob import glob + from celery.task import task import ox @@ -9,7 +11,7 @@ from item.models import get_item, Item import item.tasks import models - +import extract _INSTANCE_KEYS = ('mtime', 'path') @@ -99,3 +101,24 @@ def process_stream(fileId): if not file.item.rendered: file.item.update_timeline() return True + +@task(queue="encoding") +def update_stream(id): + s = models.Stream.objects.get(pk=id) + if not glob("%s*"%s.timeline_prefix): + s.make_timeline() + if not s.color: + s.cuts = tuple(extract.cuts(s.timeline_prefix)) + s.color = tuple(extract.average_color(s.timeline_prefix)) + s.save() + + s.file.selected = True + s.file.save() + s.file.item.update_timeline() + #make sure all derivatives exist + s.extract_derivatives() + + #update clips + for c in s.file.item.clips.all(): + c.update_calculated_values() + c.save()