fix storage paramater in get_orig_filename(), fix __init__ for ProceessImage, better...
authorRodney Ewing <ewing.rj@gmail.com>
Tue, 6 Aug 2013 17:48:26 +0000 (10:48 -0700)
committerRodney Ewing <ewing.rj@gmail.com>
Fri, 16 Aug 2013 22:30:15 +0000 (15:30 -0700)
mediagoblin/media_types/image/__init__.py
mediagoblin/media_types/image/processing.py
mediagoblin/processing/__init__.py

index 072611e7950bff0e6003380874355bd2ca5154ea..68376f7f2c6ffd7bc58780f807933ec2e2d0cec6 100644 (file)
@@ -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"
 
index 7ac3ac17b220b4048dce9033320dda5369ba7de3..c97811b1c6c8d9e8d3eb875780470ecb6cfca9a9 100644 (file)
@@ -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',
index 60565e094c799599a8c928eb854c10c6491fb549..5ce9281b584ed334e5e8707ca4dc607eb7745fd6 100644 (file)
@@ -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