Skip to content

Commit

Permalink
maybe fix flatpak
Browse files Browse the repository at this point in the history
  • Loading branch information
TNTwise committed Aug 31, 2024
1 parent da7dc5b commit b2f492d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/DownloadDeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
move,
extractTarGZ,
downloadTempDirectory,
downloadFile
downloadFile,
backendDirectory,
)
from .ui.QTcustom import DownloadProgressPopup, DisplayCommandOutputPopup
import os
Expand Down Expand Up @@ -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")
Expand Down
17 changes: 17 additions & 0 deletions src/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/ProcessTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit b2f492d

Please sign in to comment.