diff --git a/lollms/server/endpoints/lollms_sd.py b/lollms/server/endpoints/lollms_sd.py index c389016..7bf9c98 100644 --- a/lollms/server/endpoints/lollms_sd.py +++ b/lollms/server/endpoints/lollms_sd.py @@ -44,4 +44,5 @@ def install_sd(): return {"status":True} except Exception as ex: lollmsElfServer.HideBlockingMessage() + lollmsElfServer.InfoMessage(f"It looks like I could not install SD because of this error:\n{ex}\nThis is commonly caused by a previous version that I couldn't delete. PLease remove {lollmsElfServer.lollms_paths.personal_path}/shared/auto_sd manually then try again") return {"status":False, 'error':str(ex)} \ No newline at end of file diff --git a/lollms/services/sd/lollms_sd.py b/lollms/services/sd/lollms_sd.py index 0bb9492..c418f13 100644 --- a/lollms/services/sd/lollms_sd.py +++ b/lollms/services/sd/lollms_sd.py @@ -31,6 +31,7 @@ from lollms.paths import LollmsPaths from lollms.utilities import git_pull, show_yes_no_dialog import subprocess import shutil +from tqdm import tqdm def verify_sd(lollms_paths:LollmsPaths): @@ -41,11 +42,19 @@ def verify_sd(lollms_paths:LollmsPaths): return sd_folder.exists() def download_file(url, folder_path, local_filename): + # Make sure 'folder_path' exists + folder_path.mkdir(parents=True, exist_ok=True) + with requests.get(url, stream=True) as r: r.raise_for_status() - with open(folder_path + '/' + local_filename, 'wb') as f: + total_size = int(r.headers.get('content-length', 0)) + progress_bar = tqdm(total=total_size, unit='B', unit_scale=True) + with open(folder_path / local_filename, 'wb') as f: for chunk in r.iter_content(chunk_size=8192): f.write(chunk) + progress_bar.update(len(chunk)) + progress_bar.close() + return local_filename def install_sd(lollms_app:LollmsApplication):