diff --git a/src/DownloadDeps.py b/src/DownloadDeps.py index 50cef402..0efeb03c 100644 --- a/src/DownloadDeps.py +++ b/src/DownloadDeps.py @@ -9,7 +9,8 @@ move, extractTarGZ, downloadTempDirectory, - downloadFile + downloadFile, + backendDirectory, ) from .ui.QTcustom import DownloadProgressPopup, DisplayCommandOutputPopup import os @@ -65,7 +66,7 @@ def downloadBackend(self, tag): *NOTE 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")): + if not os.path.exists(backendDirectory()): 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") diff --git a/src/Util.py b/src/Util.py index 2c4a379a..ae657ed7 100644 --- a/src/Util.py +++ b/src/Util.py @@ -23,6 +23,23 @@ def isFlatpak(): with open(os.path.join(cwd, "frontend_log.txt"), "w") as f: pass +def backendDirectory(): + """ + returns cwd except when running in flatpak, then it returns the flatpak bin directory + """ + + if isFlatpak(): + # Get the absolute path of the current script + current_script_path = os.path.abspath(__file__) + + # Get the directory of the current script + current_directory = os.path.dirname(current_script_path) + + print("Current directory:", current_directory) + return current_directory + else: + return cwd + def downloadFile(link,downloadLocation): response = requests.get( link, diff --git a/src/ui/ProcessTab.py b/src/ui/ProcessTab.py index 4556f9bc..8818ac82 100644 --- a/src/ui/ProcessTab.py +++ b/src/ui/ProcessTab.py @@ -8,7 +8,7 @@ from PySide6.QtCore import Qt from .QTcustom import UpdateGUIThread -from ..Util import pythonPath, currentDirectory, modelsPath, printAndLog, log +from ..Util import pythonPath, currentDirectory, modelsPath, printAndLog, log, backendDirectory from ..DownloadModels import DownloadModel from .SettingsTab import Settings from ..DiscordRPC import start_discordRPC @@ -200,7 +200,7 @@ def renderToPipeThread(self, method: str, backend: str, interpolateTimes: int): f"{pythonPath()}", "-W", "ignore", - os.path.join(currentDirectory(), "backend", "rve-backend.py"), + os.path.join(backendDirectory(), "rve-backend.py"), "-i", self.inputFile, "-o",