File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -99,12 +99,13 @@ def warn(msg):
9999 RST = "\033 [0m"
100100 print (f"{ YELLOW } warn - { msg } { RST } " )
101101
102- def curl (url , timeout = 10 ):
102+ def curl (url , timeout = 10 , silent = False ):
103103 """Fetch a URL and return its response body as a UTF-8 string.
104104
105105 Args:
106106 url (str): The full URL to fetch.
107107 timeout (int): Request timeout in seconds.
108+ silent (bool): If True, suppress warning on failure (for retry scenarios).
108109
109110 Returns:
110111 str | None: Response body as text, or None if the request failed.
@@ -115,5 +116,6 @@ def curl(url, timeout=10):
115116 with urllib .request .urlopen (url , timeout = timeout ) as response :
116117 return response .read ().decode ('utf-8' , errors = 'replace' )
117118 except (urllib .error .URLError , ConnectionResetError , UnicodeEncodeError ) as e :
118- print (f"[WARN] curl: failed to fetch { url } : { e } " )
119+ if not silent :
120+ print (f"[WARN] curl: failed to fetch { url } : { e } " )
119121 return ""
You can’t perform that action at this time.
0 commit comments