From 9a24f5bb4b577172cecdefaa940567f1953fb4ef Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:29:40 -0800 Subject: [PATCH] Handle timeouts for Zenity popups - 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 --- ULWGL/ulwgl_dl_util.py | 3 +++ ULWGL/ulwgl_util.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ULWGL/ulwgl_dl_util.py b/ULWGL/ulwgl_dl_util.py index f04f696f..f9a52333 100644 --- a/ULWGL/ulwgl_dl_util.py +++ b/ULWGL/ulwgl_dl_util.py @@ -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( diff --git a/ULWGL/ulwgl_util.py b/ULWGL/ulwgl_util.py index b73e1614..e303d472 100644 --- a/ULWGL/ulwgl_util.py +++ b/ULWGL/ulwgl_util.py @@ -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)