Skip to content

Commit

Permalink
progress callback added to usgs api downloader see #21
Browse files Browse the repository at this point in the history
  • Loading branch information
clemcazorla committed Jun 28, 2018
1 parent d85b365 commit 3f1d23b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eodag/plugins/apis/usgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def query(self, product_type, **kwargs):
api.logout()
return final

def download(self, product, auth=None):
def download(self, product, auth=None, progress_callback=None):
url = product.location
if not url:
logger.debug('Unable to get download url for %s, skipping download', product)
Expand Down Expand Up @@ -111,10 +111,10 @@ def download(self, product, auth=None):
params=self.config.get('dl_url_params', {}), verify=False) as stream:
stream_size = int(stream.headers.get('content-length', 0))
with open(local_file_path, 'wb') as fhandle:
progressbar = tqdm(total=stream_size, unit='KB', unit_scale=True)

for chunk in stream.iter_content(chunk_size=64 * 1024):
if chunk:
progressbar.update(len(chunk))
progress_callback(len(chunk), stream_size)
fhandle.write(chunk)
try:
stream.raise_for_status()
Expand Down

0 comments on commit 3f1d23b

Please sign in to comment.