Should be enough to get to the point where you can actually initialize a processing command now.
However, it doesn't celery task-ify it... This commit sponsored by Catalin Cosovanu. Thank you!
This commit is contained in:
parent
4ba5bdd96e
commit
d1e9913b71
@ -262,7 +262,8 @@ def run(args):
|
|||||||
manager_class = hook_handle(('reprocess_manager', media_type))
|
manager_class = hook_handle(('reprocess_manager', media_type))
|
||||||
manager = manager_class()
|
manager = manager_class()
|
||||||
|
|
||||||
# TOOD: Specify in error
|
# TODO: (maybe?) This could probably be handled entirely by the
|
||||||
|
# processor class...
|
||||||
try:
|
try:
|
||||||
processor_class = manager.get_processor(
|
processor_class = manager.get_processor(
|
||||||
args.reprocess_command, media_entry)
|
args.reprocess_command, media_entry)
|
||||||
@ -277,9 +278,9 @@ def run(args):
|
|||||||
|
|
||||||
reprocess_parser = processor_class.generate_parser()
|
reprocess_parser = processor_class.generate_parser()
|
||||||
reprocess_args = reprocess_parser.parse_args(args.reprocess_args)
|
reprocess_args = reprocess_parser.parse_args(args.reprocess_args)
|
||||||
|
reprocess_request = processor_class.args_to_request(reprocess_args)
|
||||||
import pdb
|
processor = processor_class(manager, media_entry)
|
||||||
pdb.set_trace()
|
processor.process(**reprocess_request)
|
||||||
|
|
||||||
|
|
||||||
def reprocess(args):
|
def reprocess(args):
|
||||||
|
@ -26,7 +26,8 @@ from mediagoblin import mg_globals as mgg
|
|||||||
from mediagoblin.db.models import MediaEntry
|
from mediagoblin.db.models import MediaEntry
|
||||||
from mediagoblin.processing import (
|
from mediagoblin.processing import (
|
||||||
BadMediaFail, FilenameBuilder,
|
BadMediaFail, FilenameBuilder,
|
||||||
MediaProcessor, ProcessingManager)
|
MediaProcessor, ProcessingManager,
|
||||||
|
request_from_args)
|
||||||
from mediagoblin.submit.lib import run_process_media
|
from mediagoblin.submit.lib import run_process_media
|
||||||
from mediagoblin.tools.exif import exif_fix_image_orientation, \
|
from mediagoblin.tools.exif import exif_fix_image_orientation, \
|
||||||
extract_exif, clean_exif, get_gps_data, get_useful, \
|
extract_exif, clean_exif, get_gps_data, get_useful, \
|
||||||
@ -356,7 +357,8 @@ class InitialProcessor(CommonImageProcessor):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def args_to_request(cls, args):
|
def args_to_request(cls, args):
|
||||||
raise NotImplementedError
|
return request_from_args(
|
||||||
|
args, ['width', 'height'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,8 +112,9 @@ class MediaProcessor(object):
|
|||||||
# action this MediaProcessor provides
|
# action this MediaProcessor provides
|
||||||
description = None
|
description = None
|
||||||
|
|
||||||
def __init__(self, manager):
|
def __init__(self, manager, media_entry):
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
|
self.media_entry = media_entry
|
||||||
|
|
||||||
# Should be initialized at time of processing, at least
|
# Should be initialized at time of processing, at least
|
||||||
self.workbench = None
|
self.workbench = None
|
||||||
@ -138,7 +139,7 @@ class MediaProcessor(object):
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parser_to_request(cls, parser):
|
def args_to_request(cls, args):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
@ -214,6 +215,17 @@ class ProcessingManager(object):
|
|||||||
pass
|
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):
|
class ProcessingState(object):
|
||||||
"""
|
"""
|
||||||
The first and only argument to the "processor" of a media type
|
The first and only argument to the "processor" of a media type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user