Skip to content

Commit a0b366a

Browse files
committed
umu_runtime: use new enum and hashlib.file_digest
1 parent bb597f2 commit a0b366a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

umu/umu_runtime.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import os
22
from collections.abc import Callable
33
from concurrent.futures import Future, ThreadPoolExecutor
4-
from hashlib import file_digest, sha256
4+
from hashlib import sha256
55

66
try:
77
from importlib.resources.abc import Traversable
88
except ModuleNotFoundError:
99
from importlib.abc import Traversable
1010

11-
from http import HTTPMethod, HTTPStatus
11+
from http import HTTPStatus
1212
from pathlib import Path
1313
from secrets import token_urlsafe
1414
from shutil import move, rmtree
@@ -21,10 +21,11 @@
2121
from urllib3.poolmanager import PoolManager
2222
from urllib3.response import BaseHTTPResponse
2323

24-
from umu.umu_consts import UMU_CACHE, UMU_LOCAL
24+
from umu.umu_consts import UMU_CACHE, UMU_LOCAL, HTTPMethod
2525
from umu.umu_log import log
2626
from umu.umu_util import (
2727
extract_tarfile,
28+
file_digest,
2829
has_umu_setup,
2930
run_zenity,
3031
write_file_chunks,
@@ -139,7 +140,7 @@ def _install_umu(
139140

140141
# Get the digest for the runtime archive
141142
resp = http_pool.request(
142-
HTTPMethod.GET, f"{host}{endpoint}/SHA256SUMS{token}"
143+
HTTPMethod.GET.value, f"{host}{endpoint}/SHA256SUMS{token}"
143144
)
144145
if resp.status != HTTPStatus.OK:
145146
err: str = (
@@ -155,7 +156,7 @@ def _install_umu(
155156
# Get BUILD_ID.txt. We'll use the value to identify the file when cached.
156157
# This will guarantee we'll be picking up the correct file when resuming
157158
resp = http_pool.request(
158-
HTTPMethod.GET, f"{host}{endpoint}/BUILD_ID.txt{token}"
159+
HTTPMethod.GET.value, f"{host}{endpoint}/BUILD_ID.txt{token}"
159160
)
160161
if resp.status != HTTPStatus.OK:
161162
err: str = (
@@ -185,7 +186,7 @@ def _install_umu(
185186
log.info("Downloading %s (latest), please wait...", variant)
186187

187188
resp = http_pool.request(
188-
HTTPMethod.GET,
189+
HTTPMethod.GET.value,
189190
f"{host}{endpoint}/{archive}{token}",
190191
preload_content=False,
191192
headers=headers,
@@ -401,7 +402,7 @@ def _update_umu(
401402
f"{host}{endpoint}/SteamLinuxRuntime_{codename}.VERSIONS.txt{token}"
402403
)
403404
log.debug("Sending request to '%s' for 'VERSIONS.txt'...", url)
404-
resp = http_pool.request(HTTPMethod.GET, url)
405+
resp = http_pool.request(HTTPMethod.GET.value, url)
405406
if resp.status != HTTPStatus.OK:
406407
log.error(
407408
"%s returned the status: %s", resp.getheader("Host"), resp.status
@@ -539,7 +540,7 @@ def _restore_umu_platformid(
539540

540541
# Make the request to the VERSIONS.txt endpoint. It's fine to hit the
541542
# cache for this endpoint, as it differs to the latest-beta endpoint
542-
resp = http_pool.request(HTTPMethod.GET, f"{host}{url}{versions}")
543+
resp = http_pool.request(HTTPMethod.GET.value, f"{host}{url}{versions}")
543544
if resp.status != HTTPStatus.OK:
544545
log.error(
545546
"%s returned the status: %s",

0 commit comments

Comments
 (0)