Tests/store_packs.py
def download_and_extract_index(storage_bucket, extract_destination_path):
    """Downloads and extracts index zip from cloud storage.

    Args:
        storage_bucket (google.cloud.storage.bucket.Bucket): google storage bucket where index.zip is stored.
        extract_destination_path (str): the full path of extract folder.

    Returns:
        str: extracted index folder full path.
        Blob: google cloud storage object that represents index.zip blob.

    """
    index_storage_path = os.path.join(STORAGE_BASE_PATH, f"{Pack.INDEX_NAME}.zip")
    download_index_path = os.path.join(extract_destination_path, f"{Pack.INDEX_NAME}.zip")

    index_blob = storage_bucket.blob(index_storage_path)
    index_folder_path = os.path.join(extract_destination_path, Pack.INDEX_NAME)

    if not index_blob.exists():
        os.mkdir(index_folder_path)
        return index_folder_path, index_blob

    index_blob.cache_control = "no-cache"  # index zip should never be cached in the memory, should be updated version
    index_blob.reload()
    index_blob.download_to_filename(download_index_path)

    if os.path.exists(download_index_path):
        with ZipFile(download_index_path, 'r') as index_zip:
            index_zip.extractall(extract_destination_path)

        if not os.path.exists(index_folder_path):
            print_error(f"Failed creating {Pack.INDEX_NAME} folder with extracted data.")
            sys.exit(1)

        os.remove(download_index_path)
        print_color(f"Finished downloading and extracting {Pack.INDEX_NAME} file to {extract_destination_path}",
                    LOG_COLORS.GREEN)

        return index_folder_path, index_blob
    else:
        print_error(f"Failed to download {Pack.INDEX_NAME}.zip file from cloud storage.")
        sys.exit(1)
Downloads and extracts index zip from cloud storage.

    Args:
        storage_bucket (google.cloud.storage.bucket.Bucket): google storage bucket where index.zip is stored.
        extract_destination_path (str): the full path of extract folder.

    Returns:
        str: extracted index folder full path.
        Blob: google cloud storage object that represents index.zip blob.

    
Downloads and extracts index zip from cloud storage.
Downloads and extracts index zip from cloud storage .
def download_and_extract_index(storage_bucket, extract_destination_path):
    index_storage_path = os.path.join(STORAGE_BASE_PATH, f"{Pack.INDEX_NAME}.zip")
    download_index_path = os.path.join(extract_destination_path, f"{Pack.INDEX_NAME}.zip")
    index_blob = storage_bucket.blob(index_storage_path)
    index_folder_path = os.path.join(extract_destination_path, Pack.INDEX_NAME)
    if not index_blob.exists():
        os.mkdir(index_folder_path)
        return index_folder_path, index_blob
    index_blob.cache_control = "no-cache"  
    index_blob.reload()
    index_blob.download_to_filename(download_index_path)
    if os.path.exists(download_index_path):
        with ZipFile(download_index_path, 'r') as index_zip:
            index_zip.extractall(extract_destination_path)
        if not os.path.exists(index_folder_path):
            print_error(f"Failed creating {Pack.INDEX_NAME} folder with extracted data.")
            sys.exit(1)
        os.remove(download_index_path)
        print_color(f"Finished downloading and extracting {Pack.INDEX_NAME} file to {extract_destination_path}",
                    LOG_COLORS.GREEN)
        return index_folder_path, index_blob
    else:
        print_error(f"Failed to download {Pack.INDEX_NAME}.zip file from cloud storage.")
        sys.exit(1)
def download_and_extract_index ( storage_bucket , extract_destination_path ) : index_storage_path = os . path . join ( STORAGE_BASE_PATH , f"{Pack.INDEX_NAME}.zip" ) download_index_path = os . path . join ( extract_destination_path , f"{Pack.INDEX_NAME}.zip" ) index_blob = storage_bucket . blob ( index_storage_path ) index_folder_path = os . path . join ( extract_destination_path , Pack . INDEX_NAME ) if not index_blob . exists ( ) : os . mkdir ( index_folder_path ) return index_folder_path , index_blob index_blob . cache_control = "no-cache" index_blob . reload ( ) index_blob . download_to_filename ( download_index_path ) if os . path . exists ( download_index_path ) : with ZipFile ( download_index_path , 'r' ) as index_zip : index_zip . extractall ( extract_destination_path ) if not os . path . exists ( index_folder_path ) : print_error ( f"Failed creating {Pack.INDEX_NAME} folder with extracted data." ) sys . exit ( 1 ) os . remove ( download_index_path ) print_color ( f"Finished downloading and extracting {Pack.INDEX_NAME} file to {extract_destination_path}" , LOG_COLORS . GREEN ) return index_folder_path , index_blob else : print_error ( f"Failed to download {Pack.INDEX_NAME}.zip file from cloud storage." ) sys . exit ( 1 )
Downloads and extracts index zip from cloud storage.
Downloads and extracts index zip from cloud storage .
"""Downloads and extracts index zip from cloud storage.

    Args:
        storage_bucket (google.cloud.storage.bucket.Bucket): google storage bucket where index.zip is stored.
        extract_destination_path (str): the full path of extract folder.

    Returns:
        str: extracted index folder full path.
        Blob: google cloud storage object that represents index.zip blob.

    """ # index zip should never be cached in the memory, should be updated version
extracted index folder full path.
Blob: google cloud storage object that represents index.zip blob.
extracted index folder full path . Blob : google cloud storage object that represents index . zip blob .
str
storage_bucket
google storage bucket where index.zip is stored.
google storage bucket where index . zip is stored .
extract_destination_path
the full path of extract folder.
the full path of extract folder .