(bucket, prefix='')
Retrieve a list of cloud storage filepaths from the given bucket.

  Args:
    bucket: The cloud storage bucket to be queried
    prefix: Optional, a prefix used to select the objects to return
  Yields:
    Cloud storage filepaths matching the given bucket and prefix
  Raises:
    EEException:
      If there is an error in accessing the specified bucket
Retrieve a list of cloud storage filepaths from the given bucket.
Retrieve a list of cloud storage filepaths from the given bucket .
def _gcs_ls(bucket, prefix=''):
  """Retrieve a list of cloud storage filepaths from the given bucket.

  Args:
    bucket: The cloud storage bucket to be queried
    prefix: Optional, a prefix used to select the objects to return
  Yields:
    Cloud storage filepaths matching the given bucket and prefix
  Raises:
    EEException:
      If there is an error in accessing the specified bucket
  """

  base_url = 'https://storage.googleapis.com/storage/v1/b/%s/o' % bucket
  method = 'GET'
  http = ee.data.authorizeHttp(httplib2.Http(0))
  next_page_token = None

  # Loop to handle paginated responses from GCS;
  # Exits once no 'next page token' is returned
  while True:
    params = {'fields': 'items/name,nextPageToken'}
    if next_page_token:
      params['pageToken'] = next_page_token
    if prefix:
      params['prefix'] = prefix
    payload = urllib.parse.urlencode(params)

    url = base_url + '?' + payload
    try:
      response, content = http.request(url, method=method)
    except httplib2.HttpLib2Error as e:
      raise ee.ee_exception.EEException('Unexpected HTTP error: %s' % str(e))

    if response.status < 100 or response.status >= 300:
      raise ee.ee_exception.EEException(('Error retrieving bucket %s;'
                                         ' Server returned HTTP code: %d' %
                                         (bucket, response.status)))

    json_content = json.loads(content)
    if 'error' in json_content:
      json_error = json_content['error']['message']
      raise ee.ee_exception.EEException('Error retrieving bucket %s: %s' %
                                        (bucket, json_error))

    if 'items' not in json_content:
      raise ee.ee_exception.EEException(
          'Cannot find items list in the response from GCS: %s' % json_content)
    objects = json_content['items']
    object_names = [str(gc_object['name']) for gc_object in objects]

    for name in object_names:
      yield 'gs://%s/%s' % (bucket, name)

    # GCS indicates no more results
    if 'nextPageToken' not in json_content:
      return

    # Load next page, continue at beginning of while True:
    next_page_token = json_content['nextPageToken']
def _gcs_ls ( bucket , prefix = '' ) : base_url = 'https://storage.googleapis.com/storage/v1/b/%s/o' % bucket method = 'GET' http = ee . data . authorizeHttp ( httplib2 . Http ( 0 ) ) next_page_token = None # Loop to handle paginated responses from GCS; # Exits once no 'next page token' is returned while True : params = { 'fields' : 'items/name,nextPageToken' } if next_page_token : params [ 'pageToken' ] = next_page_token if prefix : params [ 'prefix' ] = prefix payload = urllib . parse . urlencode ( params ) url = base_url + '?' + payload try : response , content = http . request ( url , method = method ) except httplib2 . HttpLib2Error as e : raise ee . ee_exception . EEException ( 'Unexpected HTTP error: %s' % str ( e ) ) if response . status < 100 or response . status >= 300 : raise ee . ee_exception . EEException ( ( 'Error retrieving bucket %s;' ' Server returned HTTP code: %d' % ( bucket , response . status ) ) ) json_content = json . loads ( content ) if 'error' in json_content : json_error = json_content [ 'error' ] [ 'message' ] raise ee . ee_exception . EEException ( 'Error retrieving bucket %s: %s' % ( bucket , json_error ) ) if 'items' not in json_content : raise ee . ee_exception . EEException ( 'Cannot find items list in the response from GCS: %s' % json_content ) objects = json_content [ 'items' ] object_names = [ str ( gc_object [ 'name' ] ) for gc_object in objects ] for name in object_names : yield 'gs://%s/%s' % ( bucket , name ) # GCS indicates no more results if 'nextPageToken' not in json_content : return # Load next page, continue at beginning of while True: next_page_token = json_content [ 'nextPageToken' ]