Skip to content

Commit

Permalink
Handle case when user is offline
Browse files Browse the repository at this point in the history
- Before, an internet connection was implicitly required to run the launcher after the first launch when setting up ULWGL. This commit makes it so after the intitial setup, when the user is offline, the launcher will not hang indefinitely and will instead proceed to running the user's game. Now, A RuntimeError will only be raised if ULWGL has not been setup and the user is offline.

- Closes #60
  • Loading branch information
R1kaB3rN committed Mar 11, 2024
1 parent 15fd75b commit bbddb39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ULWGL/ulwgl_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,12 @@ def main() -> int: # noqa: D103
if "ULWGL_LOG" in os.environ:
set_log()

setup_ulwgl(root, local)
try:
setup_ulwgl(root, local)
except TimeoutError:
if not local.exists() or not any(local.iterdir()):
err: str = "ULWGL has not been setup for the user\nAn internet connection is required to setup ULWGL"
raise RuntimeError(err)

if isinstance(args, Namespace) and getattr(args, "config", None):
set_env_toml(env, args)
Expand Down
7 changes: 7 additions & 0 deletions ULWGL/ulwgl_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from urllib.request import urlopen
from ssl import create_default_context
from http.client import HTTPResponse, HTTPException
from socket import create_connection


class UnixUser:
Expand Down Expand Up @@ -147,6 +148,12 @@ def setup_ulwgl(root: Path, local: Path) -> None:
log.debug(f"Root: {root}")
log.debug(f"Local: {local}")

try:
create_connection(("1.1.1.1", 80), timeout=1)
except TimeoutError:
log.debug("User is offline")
raise

json: Dict[str, Any] = None
steam_compat: Path = Path.home().joinpath(".local/share/Steam/compatibilitytools.d")

Expand Down

0 comments on commit bbddb39

Please sign in to comment.