def _OpenBlob(self, blob_key):
    """Create an Image from the blob data read from blob_key."""

    storage_key = None

    try:
      gs_info = datastore.Get(
          datastore.Key.from_path(GS_INFO_KIND,
                                  blob_key,
                                  namespace=''))
      storage_key = gs_info['storage_key']
    except datastore_errors.EntityNotFoundError:
      pass

    if not storage_key:
      try:
        key = datastore_types.Key.from_path(blobstore.BLOB_INFO_KIND,
                                            blob_key,
                                            namespace='')
        datastore.Get(key)
        storage_key = blob_key
      except datastore_errors.Error:


        logging.exception('Blob with key %r does not exist', blob_key)
        raise apiproxy_errors.ApplicationError(
            images_service_pb.ImagesServiceError.UNSPECIFIED_ERROR)

    blobstore_stub = apiproxy_stub_map.apiproxy.GetStub("blobstore")


    try:
      blob_file = blobstore_stub.storage.OpenBlob(storage_key)
    except IOError:
      logging.exception("Could not get file for blob_key %r", blob_key)

      raise apiproxy_errors.ApplicationError(
          images_service_pb.ImagesServiceError.BAD_IMAGE_DATA)

    try:
      return Image.open(blob_file)
    except __HOLE__:
      logging.exception("Could not open image %r for blob_key %r",
                        blob_file, blob_key)

      raise apiproxy_errors.ApplicationError(
          images_service_pb.ImagesServiceError.BAD_IMAGE_DATA)
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/images/images_stub.py/ImagesServiceStub._OpenBlob