コード例 #1
0
 def generate_images(self, formats, fp, info, cdn_path):
     # delegate this to module
     try:
         for format_spec_name in formats:
             fp.seek(0)  # rewind the tape
             filename, image = resizer.resize(formats[format_spec_name], fp, info)
             self.store_in_cdn(filename, image, cdn_path)
     finally:
         fp.close()
コード例 #2
0
 def generate_images(self, formats, fp, info, cdn_path):
     # delegate this to module
     try:
         for format_spec_name in formats:
             format_spec = formats[format_spec_name]
             # if sources not present or includes file extension for this image
             if 'sources' not in format_spec or info.extension in [x.strip() for x in
                                                                   format_spec['sources'].split(',')]:
                 download = 'download' in format_spec and format_spec['download']
                 fp.seek(0)  # rewind the tape
                 filename, image = resizer.resize(format_spec, fp, info, self.logger)
                 if filename is not None and image is not None:
                     self.store_in_cdn(filename, image, cdn_path, download)
     finally:
         fp.close()
コード例 #3
0
ファイル: image_conversion.py プロジェクト: gnott/elife-bot
def generate_images(settings, formats, fp, info, publish_locations, logger):
        try:
            for format_spec_name in formats:
                format_spec = formats[format_spec_name]
                # if sources not present or includes file extension for this image
                if 'sources' not in format_spec or info.extension in [
                        x.strip() for x in format_spec['sources'].split(',')]:
                    download = 'download' in format_spec and format_spec['download']
                    fp.seek(0)  # rewind the tape
                    filename, image = resizer.resize(format_spec, fp, info, logger)
                    if filename is not None and image is not None:
                        store_in_publish_locations(settings, filename, image, publish_locations, download)
                        logger.info("Stored image %s as %s" % (filename, str(publish_locations)))
                    else:
                        raise RuntimeError("filename or image is None. resizer.resize problem.")
        finally:
            fp.close()
コード例 #4
0
 def generate_images(self, formats, fp, info, cdn_path):
     # delegate this to module
     try:
         for format_spec_name in formats:
             format_spec = formats[format_spec_name]
             # if sources not present or includes file extension for this image
             if 'sources' not in format_spec or info.extension in [
                     x.strip() for x in format_spec['sources'].split(',')
             ]:
                 download = 'download' in format_spec and format_spec[
                     'download']
                 fp.seek(0)  # rewind the tape
                 filename, image = resizer.resize(format_spec, fp, info,
                                                  self.logger)
                 if filename is not None and image is not None:
                     self.store_in_cdn(filename, image, cdn_path, download)
                     self.logger.info("Stored image %s as %s" %
                                      (filename, cdn_path))
     finally:
         fp.close()