From: Rodney Ewing Date: Tue, 27 Aug 2013 23:16:39 +0000 (-0700) Subject: skip stl processing if necessary X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b08d2c36433d2373260c3c158323f383c5384f12;p=mediagoblin.git skip stl processing if necessary --- diff --git a/mediagoblin/media_types/stl/processing.py b/mediagoblin/media_types/stl/processing.py index 77d3d86e..39949b59 100644 --- a/mediagoblin/media_types/stl/processing.py +++ b/mediagoblin/media_types/stl/processing.py @@ -144,11 +144,30 @@ class CommonStlProcessor(MediaProcessor): # copy it up! store_public(self.entry, keyname, workbench_path, filename) + def _skip_processing(self, keyname, **kwargs): + file_metadata = self.entry.get_file_metadata(keyname) + + if not file_metadata: + return False + skip = True + + if keyname == 'thumb': + if kwargs.get('thumb_size') != file_metadata.get('thumb_size'): + skip = False + else: + if kwargs.get('size') != file_metadata.get('size'): + skip = False + + return skip + def generate_thumb(self, thumb_size=None): if not thumb_size: thumb_size = (mgg.global_config['media:thumb']['max_width'], mgg.global_config['media:thumb']['max_height']) + if self._skip_processing('thumb', thumb_size=thumb_size): + return + self._snap( "thumb", "{basename}.thumb.jpg", @@ -156,11 +175,16 @@ class CommonStlProcessor(MediaProcessor): thumb_size, project="PERSP") + self.entry.set_file_metadata('thumb', thumb_size=thumb_size) + def generate_perspective(self, size=None): if not size: size = (mgg.global_config['media:medium']['max_width'], mgg.global_config['media:medium']['max_height']) + if self._skip_processing('perspective', size=size): + return + self._snap( "perspective", "{basename}.perspective.jpg", @@ -168,11 +192,16 @@ class CommonStlProcessor(MediaProcessor): size, project="PERSP") + self.entry.set_file_metadata('perspective', size=size) + def generate_topview(self, size=None): if not size: size = (mgg.global_config['media:medium']['max_width'], mgg.global_config['media:medium']['max_height']) + if self._skip_processing('top', size=size): + return + self._snap( "top", "{basename}.top.jpg", @@ -180,11 +209,16 @@ class CommonStlProcessor(MediaProcessor): self.greatest*2], size) + self.entry.set_file_metadata('top', size=size) + def generate_frontview(self, size=None): if not size: size = (mgg.global_config['media:medium']['max_width'], mgg.global_config['media:medium']['max_height']) + if self._skip_processing('front', size=size): + return + self._snap( "front", "{basename}.front.jpg", @@ -192,11 +226,16 @@ class CommonStlProcessor(MediaProcessor): self.model.average[2]], size) + self.entry.set_file_metadata('front', size=size) + def generate_sideview(self, size=None): if not size: size = (mgg.global_config['media:medium']['max_width'], mgg.global_config['media:medium']['max_height']) + if self._skip_processing('side', size=size): + return + self._snap( "side", "{basename}.side.jpg", @@ -204,6 +243,8 @@ class CommonStlProcessor(MediaProcessor): self.model.average[2]], size) + self.entry.set_file_metadata('side', size=size) + def store_dimensions(self): """ Put model dimensions into the database