diff --git a/test/infamy/util.py b/test/infamy/util.py index 4a7c80e7..174cae4a 100644 --- a/test/infamy/util.py +++ b/test/infamy/util.py @@ -99,12 +99,13 @@ def warn(msg): RST = "\033[0m" print(f"{YELLOW}warn - {msg}{RST}") -def curl(url, timeout=10): +def curl(url, timeout=10, silent=False): """Fetch a URL and return its response body as a UTF-8 string. Args: url (str): The full URL to fetch. timeout (int): Request timeout in seconds. + silent (bool): If True, suppress warning on failure (for retry scenarios). Returns: str | None: Response body as text, or None if the request failed. @@ -115,5 +116,6 @@ def curl(url, timeout=10): with urllib.request.urlopen(url, timeout=timeout) as response: return response.read().decode('utf-8', errors='replace') except (urllib.error.URLError, ConnectionResetError, UnicodeEncodeError) as e: - print(f"[WARN] curl: failed to fetch {url}: {e}") + if not silent: + print(f"[WARN] curl: failed to fetch {url}: {e}") return "" \ No newline at end of file