MCPcopy Create free account
hub / github.com/crisxuan/bestJavaer / request_remote_image

Function request_remote_image

scripts/check_article_quality.py:301–316  ·  view source on GitHub ↗
(url: str, timeout: float)

Source from the content-addressed store, hash-verified

299
300
301def request_remote_image(url: str, timeout: float) -> str | None:
302 fallback_codes = {403, 405, 501}
303 try:
304 return fetch_remote_image(url, timeout=timeout, method="HEAD")
305 except HTTPError as error:
306 if error.code not in fallback_codes:
307 return f"remote image returned HTTP {error.code}"
308 except (TimeoutError, URLError, OSError, ValueError) as error:
309 return remote_error_message(error)
310
311 try:
312 return fetch_remote_image(url, timeout=timeout, method="GET")
313 except HTTPError as error:
314 return f"remote image returned HTTP {error.code}"
315 except (TimeoutError, URLError, OSError, ValueError) as error:
316 return remote_error_message(error)
317
318
319def fetch_remote_image(url: str, *, timeout: float, method: str) -> str | None:

Callers 1

remote_image_issueFunction · 0.85

Calls 2

fetch_remote_imageFunction · 0.85
remote_error_messageFunction · 0.85

Tested by

no test coverage detected