comparison core/download.py @ 1225:c901261c6ce8 modernize

Add unit tests for core.download.
author Brian Neal <bgneal@gmail.com>
date Sun, 06 Apr 2025 15:38:29 -0500
parents ef1558941bc9
children
comparison
equal deleted inserted replaced
1224:d7c7a4777dd7 1225:c901261c6ce8
53 53
54 try: 54 try:
55 with open(path, 'wb') as fp: 55 with open(path, 'wb') as fp:
56 r.raw.decode_content = True 56 r.raw.decode_content = True
57 shutil.copyfileobj(r.raw, fp) 57 shutil.copyfileobj(r.raw, fp)
58 except requests.RequestException: 58 except IOError:
59 logger.exception("download_file download exception") 59 logger.exception("download_file download exception")
60 os.remove(path) 60 os.remove(path)
61 raise 61 raise
62 62
63 file_size = os.stat(path).st_size 63 file_size = os.stat(path).st_size