Spaces:
Runtime error
Runtime error
import os | |
import shutil | |
import sys | |
import tempfile | |
import requests | |
now_dir = os.getcwd() | |
sys.path.append(now_dir) | |
from assets.i18n.i18n import I18nAuto | |
i18n = I18nAuto() | |
gradio_temp_dir = os.path.join(tempfile.gettempdir(), "gradio") | |
if os.path.exists(gradio_temp_dir): | |
shutil.rmtree(gradio_temp_dir) | |
def download_file(url, destination_path, progress_bar): | |
os.makedirs(os.path.dirname(destination_path), exist_ok=True) | |
response = requests.get(url, stream=True) | |
block_size = 1024 | |
with open(destination_path, "wb") as file: | |
for data in response.iter_content(block_size): | |
file.write(data) | |
progress_bar.update(len(data)) | |