def _get_info(self,ident,request,src_fp=None,src_format=None):
		if self.enable_caching:
			in_cache = ident in self.info_cache
		else:
			in_cache = False

		if in_cache:
			return self.info_cache[ident]
		else:
			if not all((src_fp, src_format)):
				# get_img can pass in src_fp, src_format because it needs them
				# elsewhere; get_info does not.
				src_fp, src_format = self.resolver.resolve(ident)

			uri = Loris._base_uri_from_request(request)
			formats = self.transformers[src_format].target_formats
			
			logger.debug('Format: %s' % (src_format,))
			logger.debug('File Path: %s' % (src_fp,))
			logger.debug('Identifier: %s' % (ident,))

			# get the info
			info = ImageInfo.from_image_file(uri, src_fp, src_format, formats)

			# store
			if self.enable_caching:
				self.info_cache[ident] = info
				# pick up the timestamp... :()
				info,last_mod = self.info_cache[ident]
			else:
				last_mod = None

			return (info,last_mod)
Exemple #2
0
    def _get_info(self,ident,request,base_uri,src_fp=None,src_format=None):
        if self.enable_caching:
            in_cache = request in self.info_cache
        else:
            in_cache = False

        if in_cache:
            return self.info_cache[request]
        else:
            if not all((src_fp, src_format)):
                # get_img can pass in src_fp, src_format because it needs them
                # elsewhere; get_info does not.
                src_fp, src_format = self.resolver.resolve(ident)

            formats = self.transformers[src_format].target_formats

            self.logger.debug('Format: %s' % (src_format,))
            self.logger.debug('File Path: %s' % (src_fp,))
            self.logger.debug('Identifier: %s' % (ident,))
            self.logger.debug('Base URI: %s' % (base_uri,))

            # get the info
            info = ImageInfo.from_image_file(base_uri, src_fp, src_format, formats)

            # store
            if self.enable_caching:
                self.logger.debug('ident used to store %s: %s' % (ident,ident))
                self.info_cache[request] = info
                # pick up the timestamp... :()
                info,last_mod = self.info_cache[request]
            else:
                last_mod = None

            return (info,last_mod)
Exemple #3
0
    def _get_info(self,
                  ident,
                  request,
                  base_uri,
                  src_fp=None,
                  src_format=None):
        if self.enable_caching:
            in_cache = ident in self.info_cache
        else:
            in_cache = False

        if in_cache:
            return self.info_cache[ident]
        else:
            if not all((src_fp, src_format)):
                # get_img can pass in src_fp, src_format because it needs them
                # elsewhere; get_info does not.
                src_fp, src_format = self.resolver.resolve(ident)

            formats = self.transformers[src_format].target_formats

            logger.debug('Format: %s' % (src_format, ))
            logger.debug('File Path: %s' % (src_fp, ))
            logger.debug('Identifier: %s' % (ident, ))
            logger.debug('Base URI: %s' % (base_uri, ))

            # get the info
            info = ImageInfo.from_image_file(base_uri, src_fp, src_format,
                                             formats)

            # store
            if self.enable_caching:
                # Elusive bug. For some reason, every once in a while, ident
                # is the path on the file system rather than the URI.
                # One thing that's confusing about it is that here 'ident' is
                # used to mean the identifier slice of the request, and in the
                # info cache it's used this way, but ImageInfo.ident is URI
                # that goes in @id.
                logger.debug('ident used to store %s: %s' % (ident, ident))
                self.info_cache[ident] = info
                # pick up the timestamp... :()
                info, last_mod = self.info_cache[ident]
            else:
                last_mod = None

            return (info, last_mod)
Exemple #4
0
    def _get_info(self,ident,request,base_uri,src_fp=None,src_format=None):
        if self.enable_caching:
            in_cache = request in self.info_cache
        else:
            in_cache = False

        if in_cache:
            # src_fp may not be defined here if cached item is bad. TODO 
            #transformer = self.transformers['jp2']
            #dest_fp = src_fp[0:src_fp.rfind('/')+1] #strip off everything after last '/' in order to get folder destination
            #transformer.compress(src_fp, dest_fp)
            return self.info_cache[request]
        else:
            make_jp2 = False # set make_jp2 in case we don't go inside the if statement
            if not all((src_fp, src_format)):
                # get_img can pass in src_fp, src_format because it needs them
                # elsewhere; get_info does not.
                src_fp, src_format, make_jp2 = self.resolver.resolve(ident)

            dest_fp = src_fp[0:src_fp.rfind('/')+1] #strip off everything after last '/' in order to get folder destination
            if make_jp2:
                # Get the transformer
                transformer = self.transformers['jp2']
                logger.debug('about to call compress method')
                transformer.compress(src_fp, dest_fp)

            formats = self.transformers[src_format].target_formats

            logger.debug('Format: %s' % (src_format,))
            logger.debug('File Path: %s' % (src_fp,))
            logger.debug('Identifier: %s' % (ident,))
            logger.debug('Base URI: %s' % (base_uri,))

            # get the info
            info = ImageInfo.from_image_file(base_uri, src_fp, src_format, formats)

            # store
            if self.enable_caching:
                logger.debug('ident used to store %s: %s' % (ident,ident))
                self.info_cache[request] = info
                # pick up the timestamp... :()
                info,last_mod = self.info_cache[request]
            else:
                last_mod = None

            return (info,last_mod)
    def _get_info(self,ident,request,base_uri,src_fp=None,src_format=None):
        if self.enable_caching:
            in_cache = ident in self.info_cache
        else:
            in_cache = False

        if in_cache:
            return self.info_cache[ident]
        else:
            if not all((src_fp, src_format)):
                # get_img can pass in src_fp, src_format because it needs them
                # elsewhere; get_info does not.
                src_fp, src_format = self.resolver.resolve(ident)

            formats = self.transformers[src_format].target_formats
            
            logger.debug('Format: %s' % (src_format,))
            logger.debug('File Path: %s' % (src_fp,))
            logger.debug('Identifier: %s' % (ident,))
            logger.debug('Base URI: %s' % (base_uri,))

            # get the info
            info = ImageInfo.from_image_file(base_uri, src_fp, src_format, formats)

            # store
            if self.enable_caching:
                # Elusive bug. For some reason, every once in a while, ident
                # is the path on the file system rather than the URI.
                # One thing that's confusing about it is that here 'ident' is
                # used to mean the identifier slice of the request, and in the
                # info cache it's used this way, but ImageInfo.ident is URI
                # that goes in @id.
                logger.debug('ident used to store %s: %s' % (ident,ident))
                self.info_cache[ident] = info
                # pick up the timestamp... :()
                info,last_mod = self.info_cache[ident]
            else:
                last_mod = None

            return (info,last_mod)