Skip to content

Commit 31a3aae

Browse files
authored
Switch _safe_fetch and StepCatalog._fetch_single_catalog to use open_url for auth consistency
1 parent f365aab commit 31a3aae

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6006,7 +6006,7 @@ def workflow_step_add(
60066006
raise typer.Exit(1)
60076007

60086008
from urllib.parse import urlparse
6009-
from urllib.request import urlopen
6009+
from specify_cli.authentication.http import open_url as _open_url
60106010

60116011
def _safe_fetch(url: str) -> bytes:
60126012
parsed = urlparse(url)
@@ -6015,7 +6015,7 @@ def _safe_fetch(url: str) -> bytes:
60156015
raise ValueError(f"Refusing to fetch from non-HTTPS URL: {url}")
60166016
if not parsed.hostname:
60176017
raise ValueError(f"Refusing to fetch from URL with no hostname: {url}")
6018-
with urlopen(url, timeout=30) as resp: # noqa: S310
6018+
with _open_url(url, timeout=30) as resp:
60196019
final_url = resp.geturl()
60206020
final_parsed = urlparse(final_url)
60216021
final_is_localhost = final_parsed.hostname in ("localhost", "127.0.0.1", "::1")

src/specify_cli/workflows/catalog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ def _fetch_single_catalog(
858858
pass
859859

860860
from urllib.parse import urlparse
861-
from urllib.request import urlopen
861+
from specify_cli.authentication.http import open_url as _open_url
862862

863863
def _validate_url(url: str) -> None:
864864
parsed = urlparse(url)
@@ -877,7 +877,7 @@ def _validate_url(url: str) -> None:
877877
_validate_url(entry.url)
878878

879879
try:
880-
with urlopen(entry.url, timeout=30) as resp: # noqa: S310
880+
with _open_url(entry.url, timeout=30) as resp:
881881
_validate_url(resp.geturl())
882882
data = json.loads(resp.read().decode("utf-8"))
883883
except Exception as exc:

0 commit comments

Comments
 (0)