def get(self, location): """ Takes a `tank.store.location.Location` object that indicates where to find the image file, and returns a tuple of generator (for reading the image file) and image_size :param location `tank.store.location.Location` object, supplied from tank.store.location.get_location_from_uri() :raises `tank.exception.NotFound` if image does not exist """ loc = location.store_location chase_conn = self._make_chase_connection( auth_url=loc.chase_auth_url, user=loc.user, key=loc.key) try: (resp_headers, resp_body) = chase_conn.get_object( container=loc.container, obj=loc.obj, resp_chunk_size=self.CHUNKSIZE) except chase_client.ClientException, e: if e.http_status == httplib.NOT_FOUND: uri = location.get_store_uri() raise exception.NotFound(_("Chase could not find image at " "uri %(uri)s") % locals()) else: raise
def get(self, location): """ Takes a `tank.store.location.Location` object that indicates where to find the image file, and returns a tuple of generator (for reading the image file) and image_size :param location `tank.store.location.Location` object, supplied from tank.store.location.get_location_from_uri() :raises `tank.exception.NotFound` if image does not exist """ loc = location.store_location chase_conn = self._make_chase_connection(auth_url=loc.chase_auth_url, user=loc.user, key=loc.key) try: (resp_headers, resp_body) = chase_conn.get_object(container=loc.container, obj=loc.obj, resp_chunk_size=self.CHUNKSIZE) except chase_client.ClientException, e: if e.http_status == httplib.NOT_FOUND: uri = location.get_store_uri() raise exception.NotFound( _("Chase could not find image at " "uri %(uri)s") % locals()) else: raise
# Delete all the chunks before the object manifest itself obj_container, obj_prefix = manifest.split('/', 1) for segment in chase_conn.get_container(obj_container, prefix=obj_prefix)[1]: # TODO(jaypipes): This would be an easy area to parallelize # since we're simply sending off parallelizable requests # to Chase to delete stuff. It's not like we're going to # be hogging up network or file I/O here... chase_conn.delete_object(obj_container, segment['name']) else: chase_conn.delete_object(loc.container, loc.obj) except chase_client.ClientException, e: if e.http_status == httplib.NOT_FOUND: uri = location.get_store_uri() raise exception.NotFound(_("Chase could not find image at " "uri %(uri)s") % locals()) else: raise class ChunkReader(object): def __init__(self, fd, checksum, total): self.fd = fd self.checksum = checksum self.total = total self.bytes_read = 0 def read(self, i): left = self.total - self.bytes_read
# Delete all the chunks before the object manifest itself obj_container, obj_prefix = manifest.split('/', 1) for segment in chase_conn.get_container(obj_container, prefix=obj_prefix)[1]: # TODO(jaypipes): This would be an easy area to parallelize # since we're simply sending off parallelizable requests # to Chase to delete stuff. It's not like we're going to # be hogging up network or file I/O here... chase_conn.delete_object(obj_container, segment['name']) else: chase_conn.delete_object(loc.container, loc.obj) except chase_client.ClientException, e: if e.http_status == httplib.NOT_FOUND: uri = location.get_store_uri() raise exception.NotFound( _("Chase could not find image at " "uri %(uri)s") % locals()) else: raise class ChunkReader(object): def __init__(self, fd, checksum, total): self.fd = fd self.checksum = checksum self.total = total self.bytes_read = 0 def read(self, i):