MCPcopy Index your code
hub / github.com/blacklanternsecurity/bbot / api_download

Method api_download

bbot/modules/base.py:1314–1330  ·  view source on GitHub ↗

A wrapper around the `download()` web helper that incorporates API key cycling.

(self, url, **kwargs)

Source from the content-addressed store, hash-verified

1312 return r
1313
1314 async def api_download(self, url, **kwargs):
1315 """
1316 A wrapper around the `download()` web helper that incorporates API key cycling.
1317 """
1318 error = None
1319 raise_error = kwargs.pop("raise_error", False)
1320 for _ in range(self.api_retries):
1321 new_url, kwargs = self.prepare_api_request(url, kwargs)
1322 if "raise_error" not in kwargs:
1323 kwargs["raise_error"] = True
1324 try:
1325 return await self.helpers.download(new_url, **kwargs)
1326 except WebError as e:
1327 error = e
1328 self.cycle_api_key()
1329 if raise_error:
1330 raise error
1331
1332 def _get_retry_after(self, r):
1333 # try to get retry_after from headers first

Callers 3

download_run_logsMethod · 0.80

Calls 4

prepare_api_requestMethod · 0.95
cycle_api_keyMethod · 0.95
popMethod · 0.80
downloadMethod · 0.45

Tested by 1