MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / download_and_extract

Function download_and_extract

custom_ops/setup_ops.py:98–126  ·  view source on GitHub ↗

Download a .tar.gz file using wget to the destination directory and extract its contents without renaming the downloaded file. :param url: The URL of the .tar.gz file to download. :param destination_directory: The directory where the file should be downloaded and extracted.

(url, destination_directory)

Source from the content-addressed store, hash-verified

96
97
98def download_and_extract(url, destination_directory):
99 """
100 Download a .tar.gz file using wget to the destination directory
101 and extract its contents without renaming the downloaded file.
102
103 :param url: The URL of the .tar.gz file to download.
104 :param destination_directory: The directory where the file should be downloaded and extracted.
105 """
106 os.makedirs(destination_directory, exist_ok=True)
107
108 filename = os.path.basename(url)
109 file_path = os.path.join(destination_directory, filename)
110
111 try:
112 subprocess.run(
113 ["wget", "-O", file_path, url],
114 check=True,
115 )
116 print(f"Downloaded: {file_path}")
117
118 with tarfile.open(file_path, "r:gz") as tar:
119 tar.extractall(path=destination_directory)
120 print(f"Extracted: {file_path} to {destination_directory}")
121 os.remove(file_path)
122 print(f"Deleted downloaded file: {file_path}")
123 except subprocess.CalledProcessError as e:
124 print(f"Error downloading file: {e}")
125 except Exception as e:
126 print(f"Error extracting file: {e}")
127
128
129def get_sm_version(archs):

Callers

nothing calls this directly

Calls 3

printFunction · 0.85
joinMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected