eodag 3.3.1__py3-none-any.whl → 3.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eodag/api/product/_product.py +73 -36
- eodag/resources/ext_product_types.json +1 -1
- eodag/resources/providers.yml +3 -3
- {eodag-3.3.1.dist-info → eodag-3.3.2.dist-info}/METADATA +2 -2
- {eodag-3.3.1.dist-info → eodag-3.3.2.dist-info}/RECORD +9 -9
- {eodag-3.3.1.dist-info → eodag-3.3.2.dist-info}/WHEEL +1 -1
- {eodag-3.3.1.dist-info → eodag-3.3.2.dist-info}/entry_points.txt +0 -0
- {eodag-3.3.1.dist-info → eodag-3.3.2.dist-info}/licenses/LICENSE +0 -0
- {eodag-3.3.1.dist-info → eodag-3.3.2.dist-info}/top_level.txt +0 -0
eodag/api/product/_product.py
CHANGED
|
@@ -313,7 +313,6 @@ class EOProduct:
|
|
|
313
313
|
"EO product is unable to download itself due to lacking of a "
|
|
314
314
|
"download plugin"
|
|
315
315
|
)
|
|
316
|
-
|
|
317
316
|
auth = (
|
|
318
317
|
self.downloader_auth.authenticate()
|
|
319
318
|
if self.downloader_auth is not None
|
|
@@ -323,7 +322,6 @@ class EOProduct:
|
|
|
323
322
|
progress_callback, close_progress_callback = self._init_progress_bar(
|
|
324
323
|
progress_callback
|
|
325
324
|
)
|
|
326
|
-
|
|
327
325
|
fs_path = self.downloader.download(
|
|
328
326
|
self,
|
|
329
327
|
auth=auth,
|
|
@@ -369,6 +367,47 @@ class EOProduct:
|
|
|
369
367
|
progress_callback.refresh()
|
|
370
368
|
return (progress_callback, close_progress_callback)
|
|
371
369
|
|
|
370
|
+
def _download_quicklook(
|
|
371
|
+
self,
|
|
372
|
+
quicklook_file: str,
|
|
373
|
+
progress_callback: ProgressCallback,
|
|
374
|
+
ssl_verify: Optional[bool] = None,
|
|
375
|
+
auth: Optional[AuthBase] = None,
|
|
376
|
+
):
|
|
377
|
+
|
|
378
|
+
"""Download the quicklook image from the EOProduct's quicklook URL.
|
|
379
|
+
|
|
380
|
+
This method performs an HTTP GET request to retrieve the quicklook image and saves it
|
|
381
|
+
locally at the specified path. It optionally verifies SSL certificates, uses HTTP
|
|
382
|
+
authentication, and can display a download progress if a callback is provided.
|
|
383
|
+
|
|
384
|
+
:param quicklook_file: The full path (including filename) where the quicklook will be saved.
|
|
385
|
+
:param progress_callback: A callable that accepts the current and total download sizes
|
|
386
|
+
to display or log the download progress. It must support `reset(total)`
|
|
387
|
+
and be callable with downloaded chunk sizes.
|
|
388
|
+
:param ssl_verify: (optional) Whether to verify SSL certificates. Defaults to True.
|
|
389
|
+
:param auth: (optional) Authentication credentials (e.g., tuple or object) used for the
|
|
390
|
+
HTTP request if the resource requires authentication.
|
|
391
|
+
:raises HTTPError: If the HTTP request to the quicklook URL fails.
|
|
392
|
+
"""
|
|
393
|
+
with requests.get(
|
|
394
|
+
self.properties["quicklook"],
|
|
395
|
+
stream=True,
|
|
396
|
+
auth=auth,
|
|
397
|
+
headers=USER_AGENT,
|
|
398
|
+
timeout=DEFAULT_STREAM_REQUESTS_TIMEOUT,
|
|
399
|
+
verify=ssl_verify,
|
|
400
|
+
) as stream:
|
|
401
|
+
stream.raise_for_status()
|
|
402
|
+
stream_size = int(stream.headers.get("content-length", 0))
|
|
403
|
+
progress_callback.reset(stream_size)
|
|
404
|
+
with open(quicklook_file, "wb") as fhandle:
|
|
405
|
+
for chunk in stream.iter_content(chunk_size=64 * 1024):
|
|
406
|
+
if chunk:
|
|
407
|
+
fhandle.write(chunk)
|
|
408
|
+
progress_callback(len(chunk))
|
|
409
|
+
logger.info("Download recorded in %s", quicklook_file)
|
|
410
|
+
|
|
372
411
|
def get_quicklook(
|
|
373
412
|
self,
|
|
374
413
|
filename: Optional[str] = None,
|
|
@@ -378,6 +417,9 @@ class EOProduct:
|
|
|
378
417
|
"""Download the quicklook image of a given EOProduct from its provider if it
|
|
379
418
|
exists.
|
|
380
419
|
|
|
420
|
+
This method retrieves the quicklook URL from the EOProduct metadata and delegates
|
|
421
|
+
the download to the internal `download_quicklook` method.
|
|
422
|
+
|
|
381
423
|
:param filename: (optional) The name to give to the downloaded quicklook. If not
|
|
382
424
|
given, it defaults to the product's ID (without file extension).
|
|
383
425
|
:param output_dir: (optional) The absolute path of the directory where to store
|
|
@@ -403,18 +445,6 @@ class EOProduct:
|
|
|
403
445
|
}
|
|
404
446
|
)
|
|
405
447
|
|
|
406
|
-
# progress bar init
|
|
407
|
-
if progress_callback is None:
|
|
408
|
-
progress_callback = ProgressCallback()
|
|
409
|
-
# one shot progress callback to close after download
|
|
410
|
-
close_progress_callback = True
|
|
411
|
-
else:
|
|
412
|
-
close_progress_callback = False
|
|
413
|
-
# update units as bar may have been previously used for extraction
|
|
414
|
-
progress_callback.unit = "B"
|
|
415
|
-
progress_callback.unit_scale = True
|
|
416
|
-
progress_callback.desc = "quicklooks/%s" % self.properties.get("id", "")
|
|
417
|
-
|
|
418
448
|
if self.properties.get("quicklook", None) is None:
|
|
419
449
|
logger.warning(
|
|
420
450
|
"Missing information to retrieve quicklook for EO product: %s",
|
|
@@ -442,6 +472,18 @@ class EOProduct:
|
|
|
442
472
|
)
|
|
443
473
|
|
|
444
474
|
if not os.path.isfile(quicklook_file):
|
|
475
|
+
|
|
476
|
+
# progress bar init
|
|
477
|
+
if progress_callback is None:
|
|
478
|
+
progress_callback = ProgressCallback()
|
|
479
|
+
# one shot progress callback to close after download
|
|
480
|
+
close_progress_callback = True
|
|
481
|
+
else:
|
|
482
|
+
close_progress_callback = False
|
|
483
|
+
# update units as bar may have been previously used for extraction
|
|
484
|
+
progress_callback.unit = "B"
|
|
485
|
+
progress_callback.unit_scale = True
|
|
486
|
+
progress_callback.desc = "quicklooks/%s" % self.properties.get("id", "")
|
|
445
487
|
# VERY SPECIAL CASE (introduced by the onda provider): first check if
|
|
446
488
|
# it is a HTTP URL. If not, we assume it is a base64 string, in which case
|
|
447
489
|
# we just decode the content, write it into the quicklook_file and return it.
|
|
@@ -468,30 +510,25 @@ class EOProduct:
|
|
|
468
510
|
if self.downloader
|
|
469
511
|
else True
|
|
470
512
|
)
|
|
471
|
-
|
|
472
|
-
self.
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
timeout=DEFAULT_STREAM_REQUESTS_TIMEOUT,
|
|
477
|
-
verify=ssl_verify,
|
|
478
|
-
) as stream:
|
|
479
|
-
try:
|
|
480
|
-
stream.raise_for_status()
|
|
481
|
-
except RequestException as e:
|
|
482
|
-
import traceback as tb
|
|
513
|
+
try:
|
|
514
|
+
self._download_quicklook(
|
|
515
|
+
quicklook_file, progress_callback, ssl_verify, auth
|
|
516
|
+
)
|
|
517
|
+
except RequestException as e:
|
|
483
518
|
|
|
484
|
-
|
|
519
|
+
logger.debug(
|
|
520
|
+
f"Error while getting resource with authentication. {e} \nTrying without authentication..."
|
|
521
|
+
)
|
|
522
|
+
try:
|
|
523
|
+
self._download_quicklook(
|
|
524
|
+
quicklook_file, progress_callback, ssl_verify, None
|
|
525
|
+
)
|
|
526
|
+
except RequestException as e_no_auth:
|
|
527
|
+
logger.error(
|
|
528
|
+
f"Failed to get resource with authentication: {e} \n \
|
|
529
|
+
Failed to get resource even without authentication. {e_no_auth}"
|
|
530
|
+
)
|
|
485
531
|
return str(e)
|
|
486
|
-
else:
|
|
487
|
-
stream_size = int(stream.headers.get("content-length", 0))
|
|
488
|
-
progress_callback.reset(stream_size)
|
|
489
|
-
with open(quicklook_file, "wb") as fhandle:
|
|
490
|
-
for chunk in stream.iter_content(chunk_size=64 * 1024):
|
|
491
|
-
if chunk:
|
|
492
|
-
fhandle.write(chunk)
|
|
493
|
-
progress_callback(len(chunk))
|
|
494
|
-
logger.info("Download recorded in %s", quicklook_file)
|
|
495
532
|
|
|
496
533
|
# close progress bar if needed
|
|
497
534
|
if close_progress_callback:
|