def getGCPList(MGRS): from google.cloud import storage from oauth2client.service_account import ServiceAccountCredentials import os import firebase_admin from firebase_admin import credentials from firebase_admin import db cred = credentials.Certificate('servicekey.json') # Initialize the app with a service account, granting admin privileges #firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) storage_client = storage.Client() bucket_name = 'gcp-public-data-sentinel-2' bucket = storage_client.bucket(bucket_name) b1 = MGRS[0:2] b2 = MGRS[2:3] b3 = MGRS[3:] single_blob = 'tiles/' + b1 + '/' + b2 + '/' + b3 print(single_blob) iter = 0 latest_day = 0 latest_blob = 'a' for blob in storage_client.list_blobs(bucket_name, prefix=single_blob): blob_date = blob.name blob_date= blob_date.replace(single_blob, '') blob_date = blob_date[12:20] if iter ==0: latest_day = blob_date latest_blob = blob.name iter = iter + 1 if blob_date > latest_day: latest_day = blob_date latest_blob = blob.name print(latest_day) return latest_blob #print(blob_date)