From c541fb71f7f92ce13783400cf9b22083f38ae189 Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Tue, 6 Aug 2013 10:48:26 -0700 Subject: [PATCH] fix storage paramater in get_orig_filename(), fix __init__ for ProceessImage, better description for --size flag --- mediagoblin/media_types/image/__init__.py | 2 +- mediagoblin/media_types/image/processing.py | 26 +++++++++++---------- mediagoblin/processing/__init__.py | 4 +++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/mediagoblin/media_types/image/__init__.py b/mediagoblin/media_types/image/__init__.py index 072611e7..68376f7f 100644 --- a/mediagoblin/media_types/image/__init__.py +++ b/mediagoblin/media_types/image/__init__.py @@ -34,7 +34,7 @@ def setup_plugin(): class ImageMediaManager(MediaManagerBase): human_readable = "Image" - processor = ProcessImage + processor = staticmethod(ProcessImage) display_template = "mediagoblin/media_displays/image.html" default_thumb = "images/media_thumbs/image.png" diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py index 7ac3ac17..c97811b1 100644 --- a/mediagoblin/media_types/image/processing.py +++ b/mediagoblin/media_types/image/processing.py @@ -134,22 +134,23 @@ class ProcessImage(object): A Workbench() represents a local tempory dir. It is automatically cleaned up when this function exits. """ - def init(self, proc_state): - self.proc_state = proc_state - self.entry = proc_state.entry - self.workbench = proc_state.workbench + def __init__(self, proc_state=None): + if proc_state: + self.proc_state = proc_state + self.entry = proc_state.entry + self.workbench = proc_state.workbench - # Conversions subdirectory to avoid collisions - self.conversions_subdir = os.path.join( - self.workbench.dir, 'convirsions') + # Conversions subdirectory to avoid collisions + self.conversions_subdir = os.path.join( + self.workbench.dir, 'convirsions') - self.orig_filename = proc_state.get_orig_filename() - self.name_builder = FilenameBuilder(self.orig_filename) + self.orig_filename = proc_state.get_orig_filename() + self.name_builder = FilenameBuilder(self.orig_filename) - # Exif extraction - self.exif_tags = extract_exif(self.orig_filename) + # Exif extraction + self.exif_tags = extract_exif(self.orig_filename) - os.mkdir(self.conversions_subdir) + os.mkdir(self.conversions_subdir) def reprocess_action(self, args): """ @@ -174,6 +175,7 @@ class ProcessImage(object): parser.add_argument( '--size', nargs=2, + metavar=('max_width', 'max_height'), type=int) parser.add_argument( '--initial_processing', diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index 60565e09..5ce9281b 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -106,11 +106,13 @@ class ProcessingState(object): if self.entry.queued_media_file: orig_filepath = self.entry.queued_media_file + storage = mgg.queue_store else: orig_filepath = self.entry.media_files['original'] + storage = mgg.public_store orig_filename = self.workbench.localized_file( - mgg.queue_store, orig_filepath, + storage, orig_filepath, 'source') self.orig_filename = orig_filename return orig_filename -- 2.25.1