MCPcopy Create free account
hub / github.com/adobe/Marinus / download_file

Function download_file

python3_cron_scripts/get_censys_files.py:54–68  ·  view source on GitHub ↗

Download the file from the provided URL. Use the filename in the URL as the name of the outputed file.

(logger, url)

Source from the content-addressed store, hash-verified

52
53
54def download_file(logger, url):
55 """
56 Download the file from the provided URL.
57 Use the filename in the URL as the name of the outputed file.
58 """
59 local_filename = url.split("/")[-1]
60 logger.debug(local_filename)
61 # NOTE the stream=True parameter
62 req = requests.get(url, stream=True)
63 with open(local_filename, "wb") as out_f:
64 for chunk in req.iter_content(chunk_size=1024):
65 if chunk: # filter out keep-alive new chunks
66 out_f.write(chunk)
67 out_f.close()
68 return local_filename
69
70
71def main(logger=None):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected