Example #1
0
    def __init__(self,
                 base_path,
                 file_ext,
                 directory_layout='tms',
                 bucket_name='mapproxy',
                 profile_name=None):
        super(S3Cache, self).__init__()
        self.lock_cache_id = hashlib.md5(
            base_path.encode('utf-8') +
            bucket_name.encode('utf-8')).hexdigest()
        self.bucket_name = bucket_name
        try:
            self.bucket = self.conn().head_bucket(Bucket=bucket_name)
        except botocore.exceptions.ClientError as e:
            if e.response['Error']['Code'] == '404':
                raise S3ConnectionError('No such bucket: %s' % bucket_name)
            elif e.response['Error']['Code'] == '403':
                raise S3ConnectionError(
                    'Access denied. Check your credentials')
            else:
                reraise_exception(
                    S3ConnectionError('Unknown error: %s' % e),
                    sys.exc_info(),
                )

        self.base_path = base_path
        self.file_ext = file_ext

        self._tile_location, _ = path.location_funcs(layout=directory_layout)
Example #2
0
    def __init__(self, base_path, file_ext, directory_layout='tms', _concurrent_writer = 8, _concurrent_reader = 10, sas_token=None):
        super(AzureBlobCache, self).__init__()

        self.lock_cache_id = hashlib.md5(base_path.encode('utf-8')).hexdigest()
        self.conn = ContainerClient.from_container_url(sas_token)
        
        self.base_path = base_path
        self.file_ext = file_ext

        self._concurrent_writer = _concurrent_writer
        self._concurrent_reader = _concurrent_reader

        self._tile_location, _ = path.location_funcs(layout=directory_layout)
Example #3
0
 def __init__(self, cache_dir, file_ext, directory_layout='tc',
              link_single_color_images=False):
     """
     :param cache_dir: the path where the tile will be stored
     :param file_ext: the file extension that will be appended to
         each tile (e.g. 'png')
     """
     super(FileCache, self).__init__()
     self.lock_cache_id = hashlib.md5(cache_dir.encode('utf-8')).hexdigest()
     self.cache_dir = cache_dir
     self.file_ext = file_ext
     self.link_single_color_images = link_single_color_images
     self._tile_location, self._level_location = path.location_funcs(layout=directory_layout)
     if self._level_location is None:
         self.level_location = None # disable level based clean-ups
Example #4
0
 def __init__(self, cache_dir, file_ext, directory_layout='tc',
              link_single_color_images=False, dimensionlist=None):
     """
     :param cache_dir: the path where the tile will be stored
     :param file_ext: the file extension that will be appended to
         each tile (e.g. 'png')
     """
     super(FileCache, self).__init__()
     self.lock_cache_id = hashlib.md5(cache_dir.encode('utf-8')).hexdigest()
     self.cache_dir = cache_dir
     self.file_ext = file_ext
     self.link_single_color_images = link_single_color_images
     self.dimensionlist = dimensionlist
     self._tile_location, self._level_location = path.location_funcs(layout=directory_layout)
     if self._level_location is None:
         self.level_location = None # disable level based clean-ups
Example #5
0
    def __init__(self, base_path, file_ext, directory_layout='tms',
                 bucket_name='mapproxy', profile_name=None):
        super(S3Cache, self).__init__()
        self.lock_cache_id = hashlib.md5(base_path.encode('utf-8') + bucket_name.encode('utf-8')).hexdigest()
        self.bucket_name = bucket_name
        try:
            self.bucket = self.conn().head_bucket(Bucket=bucket_name)
        except botocore.exceptions.ClientError as e:
            if e.response['Error']['Code'] == '404':
                raise S3ConnectionError('No such bucket: %s' % bucket_name)
            elif e.response['Error']['Code'] == '403':
                raise S3ConnectionError('Access denied. Check your credentials')
            else:
                reraise_exception(
                    S3ConnectionError('Unknown error: %s' % e),
                    sys.exc_info(),
                )

        self.base_path = base_path
        self.file_ext = file_ext

        self._tile_location, _ = path.location_funcs(layout=directory_layout)