Skip to content
Snippets Groups Projects
Commit 255c054a authored by Pablo Boizeau's avatar Pablo Boizeau
Browse files

Fix bugs and facilitate debug

- `put()` then `sign()` was failing because cache was retrieving the value, when it shouldn't have
- Redirect logging to stdout
- Add http request failure info in log

See merge request !29
parent 22f97352
No related branches found
No related tags found
1 merge request!29Fix bugs and facilitate debug
Pipeline #271534 passed with warnings
......@@ -199,17 +199,17 @@ def _generic_sign_urls(
def sign_urls(urls: List[str]) -> Dict[str, str]:
"""Sign multiple URLs for get."""
"""Sign multiple URLs for GET."""
return _generic_sign_urls(urls=urls, route="sign_urls")
def sign_urls_put(urls: List[str]) -> Dict[str, str]:
"""Sign multiple URLs for put."""
"""Sign multiple URLs for PUT."""
return _generic_sign_urls(urls=urls, route="sign_urls_put")
def sign_url_put(url: str) -> str:
"""Sign a single URL for put."""
"""Sign a single URL for PUT."""
urls = sign_urls_put([url])
return urls[url]
......@@ -532,7 +532,11 @@ def _generic_get_signed_urls(
headers=headers,
timeout=10
)
response.raise_for_status()
try:
response.raise_for_status()
except Exception as e:
log.error(eval(response.content))
raise(e)
signed_url_batch = SignedURLBatch(**response.json())
if not signed_url_batch:
......@@ -551,7 +555,9 @@ def _generic_get_signed_urls(
expiry=signed_url_batch.expiry,
href=href
)
CACHE[url] = signed_url
if route == "sign_urls":
# Only put GET urls in cache
CACHE[url] = signed_url
signed_urls[url] = signed_url
log.debug(
"Got signed urls %s in %s seconds",
......
......@@ -6,12 +6,13 @@ import appdirs
import requests
import urllib3.util.retry
from .settings import Settings
import sys
# Settings
settings = Settings()
# Logger
logging.basicConfig()
logging.basicConfig(stream=sys.stdout)
log = logging.getLogger("dinamis_sdk")
log.setLevel(level=os.environ.get('LOGLEVEL', 'INFO').upper())
......
......@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "dinamis-sdk"
authors = [{name = "inrae", email = "remi.cresson@inrae.fr"}]
version = "0.3.2"
version = "0.3.3"
description = "DINAMIS SDK for Python"
requires-python = ">=3.7"
dependencies = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment