diff --git a/ulwgl_dl_util.py b/ulwgl_dl_util.py index eed17e2..ac20dcf 100644 --- a/ulwgl_dl_util.py +++ b/ulwgl_dl_util.py @@ -8,7 +8,6 @@ from http.client import HTTPSConnection, HTTPResponse, HTTPException, HTTPConnec from ssl import create_default_context from json import loads as loads_json from urllib.request import urlretrieve -from sys import stderr def get_ulwgl_proton(env: Dict[str, str]) -> Union[Dict[str, str]]: @@ -22,7 +21,7 @@ def get_ulwgl_proton(env: Dict[str, str]) -> Union[Dict[str, str]]: try: files = _fetch_releases() except HTTPException: - print("Offline.\nContinuing ...", file=stderr) + print("Offline.\nContinuing ...") cache: Path = Path.home().joinpath(".cache/ULWGL") steam_compat: Path = Path.home().joinpath(".local/share/Steam/compatibilitytools.d") @@ -115,12 +114,12 @@ def _fetch_proton( proton_dir: str = proton[: proton.find(".tar.gz")] # Proton dir # TODO: Parallelize this - print(f"Downloading {hash} ...", file=stderr) + print(f"Downloading {hash} ...") urlretrieve(hash_url, cache.joinpath(hash).as_posix()) - print(f"Downloading {proton} ...", file=stderr) + print(f"Downloading {proton} ...") urlretrieve(proton_url, cache.joinpath(proton).as_posix()) - print("Completed.", file=stderr) + print("Completed.") with cache.joinpath(proton).open(mode="rb") as file: if ( @@ -129,7 +128,7 @@ def _fetch_proton( ): err: str = "Digests mismatched.\nFalling back to cache ..." raise ValueError(err) - print(f"{proton}: SHA512 is OK", file=stderr) + print(f"{proton}: SHA512 is OK") _extract_dir(cache.joinpath(proton), steam_compat) environ["PROTONPATH"] = steam_compat.joinpath(proton_dir).as_posix() @@ -141,9 +140,9 @@ def _fetch_proton( def _extract_dir(proton: Path, steam_compat: Path) -> None: """Extract from the cache to another location.""" with tar_open(proton.as_posix(), "r:gz") as tar: - print(f"Extracting {proton} -> {steam_compat.as_posix()} ...", file=stderr) + print(f"Extracting {proton} -> {steam_compat.as_posix()} ...") tar.extractall(path=steam_compat.as_posix()) - print("Completed.", file=stderr) + print("Completed.") def _cleanup(tarball: str, proton: str, cache: Path, steam_compat: Path) -> None: @@ -151,13 +150,13 @@ def _cleanup(tarball: str, proton: str, cache: Path, steam_compat: Path) -> None We want to do this when a download for a new release is interrupted """ - print("Keyboard Interrupt.\nCleaning ...", file=stderr) + print("Keyboard Interrupt.\nCleaning ...") if cache.joinpath(tarball).is_file(): - print(f"Purging {tarball} in {cache} ...", file=stderr) + print(f"Purging {tarball} in {cache} ...") cache.joinpath(tarball).unlink() if steam_compat.joinpath(proton).is_dir(): - print(f"Purging {proton} in {steam_compat} ...", file=stderr) + print(f"Purging {proton} in {steam_compat} ...") rmtree(steam_compat.joinpath(proton).as_posix()) @@ -171,7 +170,7 @@ def _get_from_steamcompat( proton_dir: str = files[1][0][: files[1][0].find(".tar.gz")] for proton in steam_compat.glob("ULWGL-Proton*"): - print(f"{proton.name} found in: {steam_compat.as_posix()}", file=stderr) + print(f"{proton.name} found in: {steam_compat.as_posix()}") environ["PROTONPATH"] = proton.as_posix() env["PROTONPATH"] = environ["PROTONPATH"] @@ -179,8 +178,7 @@ def _get_from_steamcompat( if proton_dir and proton.name != proton_dir: print( "ULWGL-Proton is outdated.\nFor latest release, please download " - + files[1][1], - file=stderr, + + files[1][1] ) return env @@ -216,7 +214,7 @@ def _get_from_cache( if path: proton_dir: str = name[: name.find(".tar.gz")] # Proton dir - print(f"{name} found in: {path}", file=stderr) + print(f"{name} found in: {path}") try: _extract_dir(path, steam_compat) environ["PROTONPATH"] = steam_compat.joinpath(proton_dir).as_posix() @@ -225,7 +223,7 @@ def _get_from_cache( return env except KeyboardInterrupt: if steam_compat.joinpath(proton_dir).is_dir(): - print(f"Purging {proton_dir} in {steam_compat} ...", file=stderr) + print(f"Purging {proton_dir} in {steam_compat} ...") rmtree(steam_compat.joinpath(proton_dir).as_posix()) raise @@ -240,7 +238,7 @@ def _get_latest( When the digests mismatched or when interrupted, refer to cache for an old version """ if files: - print("Fetching latest release ...", file=stderr) + print("Fetching latest release ...") try: _fetch_proton(env, steam_compat, cache, files) env["PROTONPATH"] = environ["PROTONPATH"]