Skip to content

Commit

Permalink
bump to v0.2.1
Browse files Browse the repository at this point in the history
trying to make downloads safer using explicit flush, explicit close, and open with buffer. will likely need to do something more involved to ensure content-lengths are correct.
  • Loading branch information
AndrewAnnex authored Jun 28, 2021
2 parents 524e01a + 40e3e43 commit a4fed63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions moody/moody.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,14 @@ def download_edr_img_files(product, https, chunk_size):


def download_file(url, filename, chunk_size):
with closing(requests.get(url, stream=True)) as r:
with open(filename, "wb") as output:
with open(filename, "wb", chunk_size) as output:
with closing(requests.get(url, stream=True)) as r:
for chunk in tqdm(r.iter_content(chunk_size), desc=f'Downloading {filename}'):
if chunk:
output.write(chunk)
output.flush()
r.close()
output.flush()
if str(filename).endswith('.zip'):
shutil.unpack_archive(filename)
if os.path.exists(filename):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# some influences here came from https://github.com/audreyr/cookiecutter/blob/master/setup.py

version = '0.2.0'
version = '0.2.1'

with io.open('README.rst', 'r', encoding='utf-8') as readme_file:
readme = readme_file.read()
Expand Down

0 comments on commit a4fed63

Please sign in to comment.