Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add download functionality to ulwgl_run #30

Merged
merged 36 commits into from
Feb 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d1c24b1
Add download functionality to ulwgl_run
R1kaB3rN Feb 15, 2024
9a116c6
ulwgl_dl_util: fix bug when referring to cache for latest
R1kaB3rN Feb 15, 2024
621b6c1
ulwgl_dl_util: prefer joining Paths
R1kaB3rN Feb 15, 2024
2512cdc
ulwgl_dl_util: add post cleanup routine
R1kaB3rN Feb 16, 2024
ba54f16
ulwgl_dl_util: handle interrupts whenever extracting
R1kaB3rN Feb 16, 2024
08d1820
ulwgl_dl_util: handle connection timeout
R1kaB3rN Feb 16, 2024
f64b473
ulwgl_dl_util: move steamcompat to func
R1kaB3rN Feb 16, 2024
fbb6028
ulwgl_dl_util: move cache to func
R1kaB3rN Feb 16, 2024
e3563cb
ulwgl_dl_util: move cache to func
R1kaB3rN Feb 16, 2024
4691e26
ulwgl_dl_util: move download to func
R1kaB3rN Feb 16, 2024
f24dbc8
ulwgl_dl_util: print on extraction complete
R1kaB3rN Feb 16, 2024
05d7f4d
ulwgl_dl_util: move var inside block
R1kaB3rN Feb 16, 2024
9de0628
ulwgl_run: only import the func
R1kaB3rN Feb 16, 2024
f6aa2f3
ulwgl_dl_util: update comment
R1kaB3rN Feb 16, 2024
d457847
ulwgl_test: update tests for new usage
R1kaB3rN Feb 16, 2024
ecde7f6
ulwgl_dl_util: prefer using stdlib than requests module for network
R1kaB3rN Feb 17, 2024
83a59dc
ulwgl_dl_util: refactor _get_from_cache
R1kaB3rN Feb 17, 2024
3a5b4b1
ulwgl_dl_util: prefer joining paths
R1kaB3rN Feb 17, 2024
3e5e1e1
ulwgl_dl_util: delete references to requests module
R1kaB3rN Feb 17, 2024
744cedc
ulwgl_dl_util: be smarter about imports
R1kaB3rN Feb 17, 2024
71eaff0
ulwgl_dl_util: change GE-Proton -> ULWGL-Proton
R1kaB3rN Feb 17, 2024
9f2de76
ulwgl_dl_util: prefer creating a var for the Proton dir
R1kaB3rN Feb 17, 2024
f666c8f
ulwgl_run: change error msg
R1kaB3rN Feb 17, 2024
679cbff
ulwgl_dl_util: format
R1kaB3rN Feb 17, 2024
3c0534e
ulwgl_test: add test when extracting files
R1kaB3rN Feb 17, 2024
ae6d567
ulwgl_test: add test when removing files
R1kaB3rN Feb 17, 2024
9a425dd
ulwgl_test: update test when removing files
R1kaB3rN Feb 17, 2024
88a47e3
ulwgl_dl_util: fix bug when referencing old Proton from cache
R1kaB3rN Feb 18, 2024
15c483e
ulwgl_test: add tests for steam compat
R1kaB3rN Feb 18, 2024
63fba6c
ulwgl_test: add tests for cache
R1kaB3rN Feb 18, 2024
dfa8f97
ulwgl_test: update test when interrupting cache extraction
R1kaB3rN Feb 18, 2024
8f6d383
ulwgl_test: add tests for when retrieving latest Proton release
R1kaB3rN Feb 18, 2024
5e23219
ulwgl_dl_util: fix bug when printing tarball in cache
R1kaB3rN Feb 18, 2024
811ea0a
ulwgl_dl_util: add types to _cleanup
R1kaB3rN Feb 18, 2024
6423572
ulwgl_dl_util: update comments
R1kaB3rN Feb 18, 2024
45d8ce3
ulwgl_dl_util: update types
R1kaB3rN Feb 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ulwgl_dl_util: move cache to func
- Code block in which the digest mismatched, user interrupt or failure to download/no internet.
R1kaB3rN committed Feb 16, 2024

Verified

This commit was signed with the committer’s verified signature.
commit e3563cb8f330410feac9316531d70ca71c70ce3b
52 changes: 30 additions & 22 deletions ulwgl_dl_util.py
Original file line number Diff line number Diff line change
@@ -59,28 +59,10 @@ def get_ulwgl_proton(env: Dict[str, str]) -> Union[Dict[str, str], None]:
)

# Cache
# This point is reached when digests somehow mismatched or user interrupts the extraction process
for tarball in cache.glob("GE-Proton*.tar.gz"):
# Ignore the mismatched file
if files and tarball == cache.joinpath(files[1][0]):
continue

print(f"{tarball.name} found in: {cache.as_posix()}")
try:
_extract_dir(tarball, steam_compat)
environ["PROTONPATH"] = steam_compat.joinpath(
tarball.name[: tarball.name.find(".")]
).as_posix()
env["PROTONPATH"] = environ["PROTONPATH"]

return env
except KeyboardInterrupt:
proton: str = tarball.name[: tarball.name.find(".")]

if steam_compat.joinpath(proton).is_dir():
print(f"Purging {proton} in {steam_compat} ...")
rmtree(steam_compat.joinpath(proton).as_posix())
raise
# Refer to an old version previously installed
# Reached on digest mismatch, user interrupt or download failure/no internet
if _get_from_cache(env, steam_compat, cache, files, False):
return env

# No internet and cache/compat tool is empty, just return and raise an exception from the caller
return env
@@ -252,3 +234,29 @@ def _get_from_cache(
rmtree(steam_compat.joinpath(proton).as_posix())

raise

# Refer to an old version previously installed
# Reached on digest mismatch, user interrupt or download failure/no internet
for tarball in cache.glob("GE-Proton*.tar.gz"):
# Ignore the mismatched file
if files and tarball == cache.joinpath(files[1][0]):
continue

print(f"{tarball.name} found in: {cache.as_posix()}")
try:
_extract_dir(tarball, steam_compat)
environ["PROTONPATH"] = steam_compat.joinpath(
tarball.name[: tarball.name.find(".")]
).as_posix()
env["PROTONPATH"] = environ["PROTONPATH"]

break
except KeyboardInterrupt:
proton: str = tarball.name[: tarball.name.find(".")]

if steam_compat.joinpath(proton).is_dir():
print(f"Purging {proton} in {steam_compat} ...")
rmtree(steam_compat.joinpath(proton).as_posix())
raise

return env