diff --git a/dinamis_sdk/s3.py b/dinamis_sdk/s3.py index 0ea19ec..fa2e592 100644 --- a/dinamis_sdk/s3.py +++ b/dinamis_sdk/s3.py @@ -283,7 +283,7 @@ def sign_item_collection( urls = [ asset.href for item in item_collection - for asset in item.values() + for asset in item.assets.values() ] signed_urls = sign_urls(urls=urls) for item in item_collection: diff --git a/dinamis_sdk/utils.py b/dinamis_sdk/utils.py index 7b990ed..60414d8 100644 --- a/dinamis_sdk/utils.py +++ b/dinamis_sdk/utils.py @@ -9,26 +9,26 @@ logging.basicConfig(level=os.environ.get("LOGLEVEL") or "INFO") log = logging.getLogger("dinamis_sdk") -def _get_seconds(env_var_name: str) -> int: + +def _get_seconds(env_var_name: str, default: int) -> int: val = os.environ.get(env_var_name) if val: if val.isdigit(): - return int(val) - return None + log.info( + "Using %s = %s seconds", + env_var_name, + val + ) + return int(val) + return default -# Signed TTL margin default to 1800 seconds (30 minutes), or env. var. -if (ttl_margin_from_env := _get_seconds("DINAMIS_SDK_TTL_MARGIN")): - log.info( - "Setting TTL margin from environment variable to %s seconds", - ttl_margin_from_env - ) -SIGNED_URL_TTL_MARGIN = ttl_margin_from_env or 1800 -if (SIGNED_URL_DURATION_SECONDS := _get_seconds("DINAMIS_SDK_DURATION_SECONDS")): - log.info( - "Setting duration seconds from environment variable to %s seconds", - SIGNED_URL_DURATION_SECONDS - ) +# Signed TTL margin default to 1800 seconds (30 minutes), or env. var. +SIGNED_URL_TTL_MARGIN = _get_seconds("DINAMIS_SDK_TTL_MARGIN", 1800) +SIGNED_URL_DURATION_SECONDS = _get_seconds( + "DINAMIS_SDK_DURATION_SECONDS", + None +) MAX_URLS = 64 S3_STORAGE_DOMAIN = "meso.umontpellier.fr" diff --git a/setup.py b/setup.py index 3655b4b..b10cbd1 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,6 @@ "requests", "qrcode", "appdirs", - "pydantic", "pystac", "pystac_client", "pydantic>=1.7.3", @@ -13,7 +12,7 @@ setup( name="dinamis-sdk", - version="0.1.8", + version="0.1.9", description="DINAMIS SDK", python_requires=">=3.8", author="Remi Cresson", diff --git a/tests/test_super-s2.py b/tests/test_super-s2.py index 5548f21..28966b6 100644 --- a/tests/test_super-s2.py +++ b/tests/test_super-s2.py @@ -1,5 +1,6 @@ import dinamis_sdk import pystac_client +import pystac api = pystac_client.Client.open( 'https://stacapi-cdos.apps.okd.crocc.meso.umontpellier.fr', @@ -13,3 +14,6 @@ urls = [item.assets['img'].href for item in res.items()] assert len(urls) == 672 +# ItemCollection (bug #17) +ic = pystac.item_collection.ItemCollection(res.items()) +dinamis_sdk.sign_inplace(ic) \ No newline at end of file