Skip to content

Commit

Permalink
Handle timeouts for Zenity popups
Browse files Browse the repository at this point in the history
- Whenever Zenity is enabled, timeout all operations in 3 min. and crash the script when a request times out. Currently, Zenity is used when downloading Proton or the runtime platform and without either of them this launcher will not work
  • Loading branch information
R1kaB3rN committed Mar 6, 2024
1 parent 64cf5d7 commit 9a24f5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ULWGL/ulwgl_dl_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def _fetch_proton(
download_command: str = f"curl -LJ --progress-bar {proton_url} -o {cache.joinpath(proton).as_posix()}"
msg: str = f"Downloading {proton_dir} ..."
enable_zenity(download_command, msg)
except TimeoutError:
err: str = f"Unable to download {proton}\ngithub.com request timed out"
raise TimeoutError(err)
except FileNotFoundError:
print(f"Downloading {proton} ...", file=stderr)
resp: HTTPResponse = urlopen(
Expand Down
6 changes: 5 additions & 1 deletion ULWGL/ulwgl_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ def setup_runtime(root: Path, json: Dict[str, Any]) -> None: # noqa: D103
try:
msg: str = "Downloading Runtime, please wait..."
enable_zenity(download_command, msg)
except TimeoutError:
# Without the runtime, the launcher will not work
# Just exit on timeout or download failure
err: str = "Unable to download the Steam Runtime\nrepo.steampowered.com request timed out"
raise TimeoutError(err)
except FileNotFoundError:
print(f"Downloading {runtime_platform_value} ...", file=stderr)
resp: HTTPResponse = urlopen(
base_url, timeout=60, context=create_default_context()
)

# Without the runtime, the launcher will not work
if resp.status != 200:
err: str = f"Unable to download the Steam Runtime\nrepo.steampowered.com returned the status: {resp.status}"
raise HTTPException(err)
Expand Down

0 comments on commit 9a24f5b

Please sign in to comment.