from mediagoblin.tools.pluginapi import hook_handle
from mediagoblin.processing import (
ProcessorDoesNotExist, ProcessorNotEligible,
- get_entry_and_manager, get_manager_for_type)
+ get_entry_and_processing_manager, get_processing_manager_for_type)
def reprocess_parser_setup(subparser):
def available(args):
# Get the media type, either by looking up media id, or by specific type
try:
- media_entry, manager = get_entry_and_manager(args.id_or_type)
+ media_entry, manager = get_entry_and_processing_manager(args.id_or_type)
media_type = media_entry.type
except ValueError:
media_type = args.id_or_type
media_entry = None
- manager = get_manager_for_type(media_type)
+ manager = get_processing_manager_for_type(media_type)
if media_entry is None:
processors = manager.list_all_processors()
def run(args):
- media_entry, manager = get_entry_and_manager(args.media_id)
+ media_entry, manager = get_entry_and_processing_manager(args.media_id)
# TODO: (maybe?) This could probably be handled entirely by the
# processor class...
# Should be initialized at time of processing, at least
self.workbench = None
+ def __enter__(self):
+ self.workbench = mgg.workbench_manager.create()
+
+ def __exit__(self, *args):
+ self.workbench.destroy()
+ self.workbench = None
+
# @with_workbench
def process(self, **kwargs):
"""
class MediaEntryNotFound(Exception): pass
-def get_manager_for_type(media_type):
+def get_processing_manager_for_type(media_type):
"""
Get the appropriate media manager for this type
"""
return manager
-def get_entry_and_manager(media_id):
+def get_entry_and_processing_manager(media_id):
"""
Get a MediaEntry, its media type, and its manager all in one go.
if entry is None:
raise MediaEntryNotFound("Can't find media with id '%s'" % media_id)
- manager = get_manager_for_type(entry.media_type)
+ manager = get_processing_manager_for_type(entry.media_type)
return entry, manager
from mediagoblin import mg_globals as mgg
from . import mark_entry_failed, BaseProcessingFail
from mediagoblin.tools.processing import json_processing_callback
-from mediagoblin.processing import get_entry_and_manager
+from mediagoblin.processing import get_entry_and_processing_manager
_log = logging.getLogger(__name__)
logging.basicConfig()
info for the media_type.
"""
reprocess_info = reprocess_info or {}
- entry, manager = get_entry_and_manager(media_id)
+ entry, manager = get_entry_and_processing_manager(media_id)
# Try to process, and handle expected errors.
try: