From ad79f6685bd0420eee0de386e4741e2d517b05b4 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 18 Dec 2025 07:15:52 +0100 Subject: [PATCH] test: allow silencing curl connection failures on retry Signed-off-by: Joachim Wiberg --- test/infamy/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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