Renaming the processing manager stuff to be less ambiguous.
BONUS COMMIT to Ben Finney and the Free Software Melbourne crew. :) IRONY: Initially I committed this as "media manager".
This commit is contained in:
parent
a59f92f3ec
commit
55cfa34063
@ -24,7 +24,7 @@ from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
|
|||||||
from mediagoblin.tools.pluginapi import hook_handle
|
from mediagoblin.tools.pluginapi import hook_handle
|
||||||
from mediagoblin.processing import (
|
from mediagoblin.processing import (
|
||||||
ProcessorDoesNotExist, ProcessorNotEligible,
|
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 reprocess_parser_setup(subparser):
|
||||||
@ -211,12 +211,12 @@ def _set_media_state(args):
|
|||||||
def available(args):
|
def available(args):
|
||||||
# Get the media type, either by looking up media id, or by specific type
|
# Get the media type, either by looking up media id, or by specific type
|
||||||
try:
|
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
|
media_type = media_entry.type
|
||||||
except ValueError:
|
except ValueError:
|
||||||
media_type = args.id_or_type
|
media_type = args.id_or_type
|
||||||
media_entry = None
|
media_entry = None
|
||||||
manager = get_manager_for_type(media_type)
|
manager = get_processing_manager_for_type(media_type)
|
||||||
|
|
||||||
if media_entry is None:
|
if media_entry is None:
|
||||||
processors = manager.list_all_processors()
|
processors = manager.list_all_processors()
|
||||||
@ -245,7 +245,7 @@ def available(args):
|
|||||||
|
|
||||||
|
|
||||||
def run(args):
|
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
|
# TODO: (maybe?) This could probably be handled entirely by the
|
||||||
# processor class...
|
# processor class...
|
||||||
|
@ -120,6 +120,13 @@ class MediaProcessor(object):
|
|||||||
# Should be initialized at time of processing, at least
|
# Should be initialized at time of processing, at least
|
||||||
self.workbench = None
|
self.workbench = None
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.workbench = mgg.workbench_manager.create()
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
self.workbench.destroy()
|
||||||
|
self.workbench = None
|
||||||
|
|
||||||
# @with_workbench
|
# @with_workbench
|
||||||
def process(self, **kwargs):
|
def process(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -230,7 +237,7 @@ def request_from_args(args, which_args):
|
|||||||
class MediaEntryNotFound(Exception): pass
|
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
|
Get the appropriate media manager for this type
|
||||||
"""
|
"""
|
||||||
@ -240,7 +247,7 @@ def get_manager_for_type(media_type):
|
|||||||
return manager
|
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.
|
Get a MediaEntry, its media type, and its manager all in one go.
|
||||||
|
|
||||||
@ -250,7 +257,7 @@ def get_entry_and_manager(media_id):
|
|||||||
if entry is None:
|
if entry is None:
|
||||||
raise MediaEntryNotFound("Can't find media with id '%s'" % media_id)
|
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
|
return entry, manager
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ from celery import registry, task
|
|||||||
from mediagoblin import mg_globals as mgg
|
from mediagoblin import mg_globals as mgg
|
||||||
from . import mark_entry_failed, BaseProcessingFail
|
from . import mark_entry_failed, BaseProcessingFail
|
||||||
from mediagoblin.tools.processing import json_processing_callback
|
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__)
|
_log = logging.getLogger(__name__)
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
@ -79,7 +79,7 @@ class ProcessMedia(task.Task):
|
|||||||
info for the media_type.
|
info for the media_type.
|
||||||
"""
|
"""
|
||||||
reprocess_info = reprocess_info or {}
|
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 to process, and handle expected errors.
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user