diff --git a/moody/moody.py b/moody/moody.py index 0bc69ca..c92e5ad 100644 --- a/moody/moody.py +++ b/moody/moody.py @@ -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): diff --git a/setup.py b/setup.py index 29de4b0..831f09a 100644 --- a/setup.py +++ b/setup.py @@ -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()