diff --git a/ULWGL/ulwgl_run.py b/ULWGL/ulwgl_run.py index 3efd3761d..dbcffc59b 100755 --- a/ULWGL/ulwgl_run.py +++ b/ULWGL/ulwgl_run.py @@ -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) diff --git a/ULWGL/ulwgl_util.py b/ULWGL/ulwgl_util.py index 5711226d6..b02e1c930 100644 --- a/ULWGL/ulwgl_util.py +++ b/ULWGL/ulwgl_util.py @@ -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: @@ -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")