However, it doesn't celery task-ify it...
This commit sponsored by Catalin Cosovanu. Thank you!
manager_class = hook_handle(('reprocess_manager', media_type))
manager = manager_class()
- # TOOD: Specify in error
+ # TODO: (maybe?) This could probably be handled entirely by the
+ # processor class...
try:
processor_class = manager.get_processor(
args.reprocess_command, media_entry)
reprocess_parser = processor_class.generate_parser()
reprocess_args = reprocess_parser.parse_args(args.reprocess_args)
-
- import pdb
- pdb.set_trace()
+ reprocess_request = processor_class.args_to_request(reprocess_args)
+ processor = processor_class(manager, media_entry)
+ processor.process(**reprocess_request)
def reprocess(args):
from mediagoblin.db.models import MediaEntry
from mediagoblin.processing import (
BadMediaFail, FilenameBuilder,
- MediaProcessor, ProcessingManager)
+ MediaProcessor, ProcessingManager,
+ request_from_args)
from mediagoblin.submit.lib import run_process_media
from mediagoblin.tools.exif import exif_fix_image_orientation, \
extract_exif, clean_exif, get_gps_data, get_useful, \
@classmethod
def args_to_request(cls, args):
- raise NotImplementedError
+ return request_from_args(
+ args, ['width', 'height'])
# action this MediaProcessor provides
description = None
- def __init__(self, manager):
+ def __init__(self, manager, media_entry):
self.manager = manager
+ self.media_entry = media_entry
# Should be initialized at time of processing, at least
self.workbench = None
raise NotImplementedError
@classmethod
- def parser_to_request(cls, parser):
+ def args_to_request(cls, args):
raise NotImplementedError
##########################################
pass
+def request_from_args(args, which_args):
+ """
+ Generate a request from the values of some argparse parsed args
+ """
+ request = {}
+ for arg in which_args:
+ request[arg] = getattr(args, arg)
+
+ return request
+
+
class ProcessingState(object):
"""
The first and only argument to the "processor" of a media type