aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/processing
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2012-07-11 00:36:42 +0200
committerJoar Wandborg <git@wandborg.com>2012-07-11 00:36:42 +0200
commit6471291575c97f03d129051dc3d2bef28b4d89f2 (patch)
tree0c1252c0c23c2978736dd6eb819aefa89c1e355a /mediagoblin/processing
parent51eb0267d901bafcc90879dadbc2b8616ecdc4f5 (diff)
downloadmediagoblin-6471291575c97f03d129051dc3d2bef28b4d89f2.tar.lz
mediagoblin-6471291575c97f03d129051dc3d2bef28b4d89f2.tar.xz
mediagoblin-6471291575c97f03d129051dc3d2bef28b4d89f2.zip
Panel improvements
- Added progress meter for video and audio media types. - Changed the __repr__ method of a MediaEntry to display a bit more useful explanation. - Added a new MediaEntry.state, 'processing', which means that the task is running the processor on the item currently. - Fixed some PEP8 issues in user_pages/views.py - Fixed the ATOM TAG URI to show the correct year.
Diffstat (limited to 'mediagoblin/processing')
-rw-r--r--mediagoblin/processing/__init__.py11
-rw-r--r--mediagoblin/processing/task.py19
2 files changed, 21 insertions, 9 deletions
diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py
index 85b61880..6b2d50e2 100644
--- a/mediagoblin/processing/__init__.py
+++ b/mediagoblin/processing/__init__.py
@@ -25,12 +25,23 @@ from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
_log = logging.getLogger(__name__)
+class ProgressCallback(object):
+ def __init__(self, entry):
+ self.entry = entry
+
+ def __call__(self, progress):
+ if progress:
+ self.entry.transcoding_progress = progress
+ self.entry.save()
+
+
def create_pub_filepath(entry, filename):
return mgg.public_store.get_unique_filepath(
['media_entries',
unicode(entry._id),
filename])
+
class FilenameBuilder(object):
"""Easily slice and dice filenames.
diff --git a/mediagoblin/processing/task.py b/mediagoblin/processing/task.py
index af815362..58e36a11 100644
--- a/mediagoblin/processing/task.py
+++ b/mediagoblin/processing/task.py
@@ -44,20 +44,24 @@ 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)
+
+ entry.state = u'processing'
+ entry.save()
+
_log.debug('Processing {0}'.format(entry))
+
manager['processor'](entry)
+
+ entry.state = u'processed'
+ entry.save()
+
except BaseProcessingFail as exc:
mark_entry_failed(entry._id, exc)
return
+
except ImportError as exc:
_log.error(
'Entry {0} failed to process due to an import error: {1}'\
@@ -67,9 +71,6 @@ class ProcessMedia(Task):
mark_entry_failed(entry._id, exc)
- entry.state = u'processed'
- entry.save()
-
def on_failure(self, exc, task_id, args, kwargs, einfo):
"""
If the processing failed we should mark that in the database.