import logging
from mediagoblin import mg_globals as mgg
-from mediagoblin.decorators import get_workbench
from mediagoblin.processing import create_pub_filepath
from mediagoblin.media_types.ascii import asciitoimage
return False
-@get_workbench
-def process_ascii(entry, workbench=None):
+def process_ascii(proc_state):
"""Code to process a txt file. Will be run by celery.
A Workbench() represents a local tempory dir. It is automatically
cleaned up when this function exits.
"""
+ entry = proc_state.entry
+ workbench = proc_state.workbench
ascii_config = mgg.global_config['media_type:mediagoblin.media_types.ascii']
# Conversions subdirectory to avoid collisions
conversions_subdir = os.path.join(
import os
from mediagoblin import mg_globals as mgg
-from mediagoblin.decorators import get_workbench
from mediagoblin.processing import (create_pub_filepath, BadMediaFail,
FilenameBuilder, ProgressCallback)
return False
-@get_workbench
-def process_audio(entry, workbench=None):
+def process_audio(proc_state):
"""Code to process uploaded audio. Will be run by celery.
A Workbench() represents a local tempory dir. It is automatically
cleaned up when this function exits.
"""
+ entry = proc_state.entry
+ workbench = proc_state.workbench
audio_config = mgg.global_config['media_type:mediagoblin.media_types.audio']
queued_filepath = entry.queued_media_file
return False
-def process_image(entry):
+def process_image(proc_state):
"""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
+ entry = proc_state.entry
workbench = proc_state.workbench
# Conversions subdirectory to avoid collisions
import pkg_resources
from mediagoblin import mg_globals as mgg
-from mediagoblin.decorators import get_workbench
from mediagoblin.processing import create_pub_filepath, \
FilenameBuilder
env=env)
-@get_workbench
-def process_stl(entry, workbench=None):
+def process_stl(proc_state):
"""Code to process an stl or obj model. Will be run by celery.
A Workbench() represents a local tempory dir. It is automatically
cleaned up when this function exits.
"""
+ entry = proc_state.entry
+ workbench = proc_state.workbench
+
queued_filepath = entry.queued_media_file
queued_filename = workbench.localized_file(
mgg.queue_store, queued_filepath, 'source')
return False
-def process_video(entry):
+def process_video(proc_state):
"""
Process a video entry, transcode the queued media files (originals) and
create a thumbnail for the entry.
A Workbench() represents a local tempory dir. It is automatically
cleaned up when this function exits.
"""
- proc_state = entry.proc_state
+ entry = proc_state.entry
workbench = proc_state.workbench
video_config = mgg.global_config['media_type:mediagoblin.media_types.video']
self.workbench = None
self.queued_filename = None
- # Monkey patch us onto the entry
- # This is needed to keep the current calling convention
- # for processors:
- # def process_FOO(entry):
- # proc_state = entry.proc_state
- # workbench = proc_state.workbench
- # When all processors use the new stuff, they should be
- # rewritten:
- # def process_FOO(proc_state):
- # entry = proc_state.entry
- # workbench = proc_state.workbench
- entry.proc_state = self
-
def set_workbench(self, wb):
self.workbench = wb
with mgg.workbench_manager.create() as workbench:
proc_state.set_workbench(workbench)
# run the processing code
- entry.media_manager['processor'](entry)
+ entry.media_manager['processor'](proc_state)
# We set the state to processed and save the entry here so there's
# no need to save at the end of the processing stage, probably ;)