diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2013-01-23 19:44:28 +0100 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2013-02-08 10:05:42 +0100 |
commit | 93b14fc300618e8b2c4ebfd54b9c59369ce0f417 (patch) | |
tree | 6c2c73bd2ce5a1671884913f12bab5cf2aec3abd /mediagoblin/media_types | |
parent | 9d7c69fb74283d15589d8ed970d5b3bd1cfee2f0 (diff) | |
download | mediagoblin-93b14fc300618e8b2c4ebfd54b9c59369ce0f417.tar.lz mediagoblin-93b14fc300618e8b2c4ebfd54b9c59369ce0f417.tar.xz mediagoblin-93b14fc300618e8b2c4ebfd54b9c59369ce0f417.zip |
Implement ProcessingState class and use for images
The idea is to have a class that has the knowledge of the
currently being processed media and also has tools for
that.
The long term idea is to make reprocessing easier by for
example hiding the way the original comes into the
processing code.
Diffstat (limited to 'mediagoblin/media_types')
-rw-r--r-- | mediagoblin/media_types/image/processing.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py index 99be848f..541e5109 100644 --- a/mediagoblin/media_types/image/processing.py +++ b/mediagoblin/media_types/image/processing.py @@ -19,7 +19,6 @@ import os import logging from mediagoblin import mg_globals as mgg -from mediagoblin.decorators import get_workbench from mediagoblin.processing import BadMediaFail, \ create_pub_filepath, FilenameBuilder from mediagoblin.tools.exif import exif_fix_image_orientation, \ @@ -95,21 +94,21 @@ def sniff_handler(media_file, **kw): return False -@get_workbench -def process_image(entry, workbench=None): +def process_image(entry): """Code to process an image. Will be run by celery. A Workbench() represents a local tempory dir. It is automatically cleaned up when this function exits. """ + proc_state = entry.proc_state + workbench = proc_state.workbench + # Conversions subdirectory to avoid collisions conversions_subdir = os.path.join( workbench.dir, 'conversions') os.mkdir(conversions_subdir) - queued_filepath = entry.queued_media_file - queued_filename = workbench.localized_file( - mgg.queue_store, queued_filepath, - 'source') + + queued_filename = proc_state.get_queued_filename() name_builder = FilenameBuilder(queued_filename) # EXIF extraction @@ -147,8 +146,7 @@ def process_image(entry, workbench=None): mgg.public_store.copy_local_to_storage(queued_filename, original_filepath) # Remove queued media file from storage and database - mgg.queue_store.delete_file(queued_filepath) - entry.queued_media_file = [] + proc_state.delete_queue_file() # Insert media file information into database media_files_dict = entry.setdefault('media_files', {}) |