From 710be00ce594e0c32fdf3bb1ad08b58b11480a16 Mon Sep 17 00:00:00 2001 From: tntwise Date: Sat, 31 Aug 2024 21:04:32 +0000 Subject: [PATCH] fix backend --- src/DownloadDeps.py | 20 +++++++++++--------- src/Util.py | 11 +++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/DownloadDeps.py b/src/DownloadDeps.py index ac79a34f..50cef402 100644 --- a/src/DownloadDeps.py +++ b/src/DownloadDeps.py @@ -9,6 +9,7 @@ move, extractTarGZ, downloadTempDirectory, + downloadFile ) from .ui.QTcustom import DownloadProgressPopup, DisplayCommandOutputPopup import os @@ -65,8 +66,8 @@ def downloadBackend(self, tag): tag is unused for now, as still in active development. just downloads the latest backend. """ if not os.path.exists(os.path.join(currentDirectory(), "backend")): - backend_url = "https://github.com/tntwise/REAL-Video-Enhancer/archive/refs/heads/2.0.zip" - main_zip = os.path.join(currentDirectory(), "repo.zip") + backend_url = "https://github.com/TNTwise/real-video-enhancer-models/releases/download/flatpak-backends/backend-V2-stable.tar.gz" + main_zip = os.path.join(currentDirectory(), "backend.tar.gz") main_folder = os.path.join(currentDirectory(), "repo") orig_backend_folder = os.path.join( main_folder, "REAL-Video-Enhancer-2.0", "backend" @@ -75,14 +76,15 @@ def downloadBackend(self, tag): printAndLog("Downloading backend") #urllib.request.urlretrieve(backend_url, main_zip) - DownloadProgressPopup(link=backend_url, downloadLocation=main_zip,title="Downloading Backend") - + downloadFile(link=backend_url, downloadLocation=main_zip) printAndLog("Extracting backend") - shutil.unpack_archive(main_zip, main_folder) - printAndLog("Moving Backend") - move(orig_backend_folder, moved_backed_folder) - printAndLog("Cleaning up") - os.remove(main_zip) + extractTarGZ(main_zip) + #printAndLog("Extracting backend") + #shutil.unpack_archive(main_zip, main_folder) + #printAndLog("Moving Backend") + #move(orig_backend_folder, moved_backed_folder) + #printAndLog("Cleaning up") + def downloadPython(self): link = "https://github.com/indygreg/python-build-standalone/releases/download/20240814/cpython-3.11.9+20240814-" diff --git a/src/Util.py b/src/Util.py index 66749590..2c4a379a 100644 --- a/src/Util.py +++ b/src/Util.py @@ -23,6 +23,17 @@ def isFlatpak(): with open(os.path.join(cwd, "frontend_log.txt"), "w") as f: pass +def downloadFile(link,downloadLocation): + response = requests.get( + link, + stream=True, + ) + printAndLog("Downloading: " + link) + with open(downloadLocation, "wb") as f: + chunk_size = 1024 + for chunk in response.iter_content(chunk_size=chunk_size): + f.write(chunk) + def downloadTempDirectory() -> str: tmppath = os.path.join(cwd, "temp") createDirectory(tmppath)