forked from Boria138/PortProtonQt
fix(get_portproton_start_command): Check if flatpak command exists before trying to run it
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
@@ -183,23 +183,39 @@ def get_portproton_start_command():
|
|||||||
if not portproton_path:
|
if not portproton_path:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Check if flatpak command exists before trying to run it
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
subprocess.run(
|
||||||
["flatpak", "list"],
|
["flatpak", "--version"],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
check=False,
|
check=False,
|
||||||
timeout=10
|
timeout=5
|
||||||
)
|
)
|
||||||
if "ru.linux_gaming.PortProton" in result.stdout:
|
flatpak_available = True
|
||||||
logger.info("Detected Flatpak installation")
|
except FileNotFoundError:
|
||||||
return ["flatpak", "run", "ru.linux_gaming.PortProton"]
|
flatpak_available = False
|
||||||
except subprocess.TimeoutExpired:
|
except Exception:
|
||||||
logger.warning("Flatpak list command timed out")
|
flatpak_available = False
|
||||||
return None
|
|
||||||
except Exception as e:
|
if flatpak_available:
|
||||||
logger.warning(f"Error checking flatpak list: {e}")
|
try:
|
||||||
pass
|
result = subprocess.run(
|
||||||
|
["flatpak", "list"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=False,
|
||||||
|
timeout=10
|
||||||
|
)
|
||||||
|
if "ru.linux_gaming.PortProton" in result.stdout:
|
||||||
|
logger.info("Detected Flatpak installation")
|
||||||
|
return ["flatpak", "run", "ru.linux_gaming.PortProton"]
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
logger.warning("Flatpak list command timed out")
|
||||||
|
return None
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Error checking flatpak list: {e}")
|
||||||
|
pass
|
||||||
|
|
||||||
start_sh_path = os.path.join(portproton_path, "data", "scripts", "start.sh")
|
start_sh_path = os.path.join(portproton_path, "data", "scripts", "start.sh")
|
||||||
if os.path.exists(start_sh_path):
|
if os.path.exists(start_sh_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user