From 1f4d6e546ff2f63b8b1a8d2c397758bd54c6d510 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 25 Dec 2010 19:15:19 +0530 Subject: [PATCH] dont set task_id, only create poster if timeline exists, do not update poster in update_imdb --- etc/init/pandora-encoding.conf | 7 +++++-- etc/init/pandora-tasks.conf | 5 ++++- pandora/archive/views.py | 6 ++---- pandora/item/models.py | 31 +++++++++++++++++-------------- pandora/item/tasks.py | 5 ++--- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/etc/init/pandora-encoding.conf b/etc/init/pandora-encoding.conf index 14715980..bd441001 100644 --- a/etc/init/pandora-encoding.conf +++ b/etc/init/pandora-encoding.conf @@ -15,6 +15,9 @@ env HOME=/home/pandora script test -e /var/log/pandora || (mkdir -p /var/log/pandora && chown $USER:$USER /var/log/pandora) cd $VENV/pandora -exec /usr/bin/sudo -u pandora $VENV/bin/python $VENV/pandora/manage.py celeryd \ - -Q encoding -f /var/log/pandora/pandora-encoding.log -l INFO +exec /usr/bin/sudo -u $USER $VENV/bin/python $VENV/pandora/manage.py celeryd \ + -Q encoding \ + -n pandora-encoding \ + -f /var/log/pandora/pandora-encoding.log \ + -l INFO end script diff --git a/etc/init/pandora-tasks.conf b/etc/init/pandora-tasks.conf index 8deff380..e1d5b512 100644 --- a/etc/init/pandora-tasks.conf +++ b/etc/init/pandora-tasks.conf @@ -16,5 +16,8 @@ script test -e /var/log/pandora || (mkdir -p /var/log/pandora && chown $USER:$USER /var/log/pandora) cd $VENV/pandora exec /usr/bin/sudo -u pandora $VENV/bin/python $VENV/pandora/manage.py celeryd \ - -Q default -f /var/log/pandora/pandora-tasks.log -l INFO + -Q default \ + -n pandora-default \ + -f /var/log/pandora/pandora-tasks.log \ + -l INFO end script diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 9fe0e4d4..cc7dd12b 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -80,8 +80,7 @@ def update(request): if 'files' in data: #update files info async, this takes to long otherwise #FIXME: how can client know if update is done? possibly with taksStatus? - task_id = '_'.join(['update', user.username, data['volume']]) - t = tasks.update_files.apply_async(args=[user.username, data['volume'], data['files']], task_id=task_id) + t = tasks.update_files.delay(user.username, data['volume'], data['files']) response['data']['taskId'] = t.task_id user_profile = user.get_profile() @@ -189,8 +188,7 @@ def firefogg_upload(request): f.save() #FIXME: this fails badly if rabbitmq goes down try: - taks_id = 'update_streams_%s' % f.item.itemId - t = item.tasks.update_streams.apply_async(args=[f.item.itemId], task_id=task_id) + t = item.tasks.update_streams.delay((f.item.itemId)) data['resultUrl'] = t.task_id except: pass diff --git a/pandora/item/models.py b/pandora/item/models.py index 3c6016fa..a17b470a 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -21,6 +21,7 @@ from django.conf import settings from ox.django import fields import ox from ox import stripTags +import ox.web.imdb from ox.normalize import canonicalTitle, canonicalName from firefogg import Firefogg @@ -572,7 +573,8 @@ class Item(models.Model): s.color = int(sum(self.data.get('color', []))) s.cuts = len(self.data.get('cuts', [])) - s.cutsperminute = s.cuts / (s.duration/60) + if s.duration: + s.cutsperminute = s.cuts / (s.duration/60) for key in ('title', 'language', 'country') + self.person_keys: setattr(s, '%s_desc'%key, getattr(s, key)) if not getattr(s, key): @@ -758,19 +760,20 @@ class Item(models.Model): frame = posters[poster] timeline = self.path('timeline.64.png') timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline)) - cmd = [settings.ITEM_POSTER, - '-t', self.get('title'), - '-d', ', '.join(self.get('directors', ['Unknown Director'])), - '-y', str(self.get('year', '')), - '-f', frame, - '-l', timeline, - '-p', poster - ] - if len(self.itemId) == 7: - cmd += ['-i', self.itemId] - cmd += ['-o', self.oxdbId] - p = subprocess.Popen(cmd) - p.wait() + if os.path.exists(timeline): + cmd = [settings.ITEM_POSTER, + '-t', self.get('title'), + '-d', ', '.join(self.get('directors', ['Unknown Director'])), + '-y', str(self.get('year', '')), + '-f', frame, + '-l', timeline, + '-p', poster + ] + if len(self.itemId) == 7: + cmd += ['-i', self.itemId] + cmd += ['-o', self.oxdbId] + p = subprocess.Popen(cmd) + p.wait() return posters.keys() class ItemFind(models.Model): diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index b0efb2df..2a90a681 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -17,10 +17,9 @@ def update_poster(itemId): item.make_poster(True) @task(ignore_resulsts=True, queue='default') -def update_imdb(imdbId): - item = models.Item.objects.get(itemId=imdbId) +def update_imdb(itemId): + item = models.Item.objects.get(itemId=itemId) item.update_imdb() - update_poster(itemId) @task(queue="encoding") def update_streams(itemId):