From 51eb0267d901bafcc90879dadbc2b8616ecdc4f5 Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Tue, 10 Jul 2012 17:53:37 +0200 Subject: [PATCH] Minor improvements to the processing panel - It is now possible to actually see what's processing, due to a bug fix where __getitem__ was called on the db model. - Removed DEPRECATED message from the docstring, it wasn't true. --- mediagoblin/db/mixin.py | 4 ++-- mediagoblin/media_types/video/processing.py | 11 ++++++++++- mediagoblin/processing/task.py | 13 +++++++++---- .../mediagoblin/user_pages/processing_panel.html | 13 ++++++++++++- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index fe6dc796..9f9b8786 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -116,8 +116,8 @@ class MediaEntryMixin(object): """ Get the exception that's appropriate for this error """ - if self['fail_error']: - return common.import_component(self['fail_error']) + if self.fail_error: + return common.import_component(self.fail_error) def get_license_data(self): """Return license dict for requested license""" diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py index 5bbcc92f..85e83352 100644 --- a/mediagoblin/media_types/video/processing.py +++ b/mediagoblin/media_types/video/processing.py @@ -19,13 +19,22 @@ import logging from mediagoblin import mg_globals as mgg from mediagoblin.processing import \ - create_pub_filepath, FilenameBuilder + create_pub_filepath, FilenameBuilder, BaseProcessingFail +from mediagoblin.tools.translate import lazy_pass_to_ugettext as _ + from . import transcoders _log = logging.getLogger(__name__) _log.setLevel(logging.DEBUG) +class VideoTranscodingFail(BaseProcessingFail): + ''' + Error raised if video transcoding fails + ''' + general_message = _(u'Video transcoding failed') + + def sniff_handler(media_file, **kw): transcoder = transcoders.VideoTranscoder() data = transcoder.discover(media_file.name) diff --git a/mediagoblin/processing/task.py b/mediagoblin/processing/task.py index 901d293b..af815362 100644 --- a/mediagoblin/processing/task.py +++ b/mediagoblin/processing/task.py @@ -24,6 +24,8 @@ from mediagoblin.media_types import get_media_manager from mediagoblin.processing import mark_entry_failed, BaseProcessingFail _log = logging.getLogger(__name__) +logging.basicConfig() +_log.setLevel(logging.DEBUG) ################################ @@ -32,8 +34,6 @@ _log = logging.getLogger(__name__) class ProcessMedia(Task): """ - DEPRECATED -- This now resides in the individual media plugins - Pass this entry off for processing. """ def run(self, media_id): @@ -44,16 +44,21 @@ class ProcessMedia(Task): entry = mgg.database.MediaEntry.one( {'_id': ObjectId(media_id)}) + _log.info('Running task {0} on media {1}: {2}'.format( + self.name, + entry._id, + entry.title)) + # Try to process, and handle expected errors. try: #__import__(entry.media_type) manager = get_media_manager(entry.media_type) _log.debug('Processing {0}'.format(entry)) manager['processor'](entry) - except BaseProcessingFail, exc: + except BaseProcessingFail as exc: mark_entry_failed(entry._id, exc) return - except ImportError, exc: + except ImportError as exc: _log.error( 'Entry {0} failed to process due to an import error: {1}'\ .format( diff --git a/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html b/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html index 65549860..e868456b 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html +++ b/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html @@ -30,12 +30,14 @@ {% if processing_entries.count() %} + {% for media_entry in processing_entries %} + @@ -51,15 +53,24 @@
ID Title When submitted Status
{{ media_entry._id }} {{ media_entry.title }} {{ media_entry.created.strftime("%m-%d-%Y %I:%M %p") }}
+ + {% for media_entry in failed_entries %} + - + + {% if media_entry.get_fail_exception() %} + + {% else %} + + + {% endif %} {% endfor %}
ID Title When submitted Reason for failureFailure metadata
{{ media_entry._id }} {{ media_entry.title }}{{ media_entry['created'].strftime("%m-%d-%Y %I:%M %p") }}{{ media_entry.created.strftime("%m-%d-%Y %I:%M %p") }}{{ media_entry.get_fail_exception().general_message }}{{ media_entry.fail_metadata }}  
-- 2.25.1