Skip to content

Commit

Permalink
Merge pull request galaxyproject#18510 from nsoranzo/release_23.2_fix…
Browse files Browse the repository at this point in the history
…_ApiBiotoolsMetadataSource._raw_get_metadata

[23.2] Handle all requests error in ``ApiBiotoolsMetadataSource._raw_get_metadata``
  • Loading branch information
nsoranzo authored Jul 8, 2024
2 parents 06590c9 + 4ac6a1e commit 1b0b82f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/galaxy/tool_util/biotools/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ def __init__(self, cache=None):

def _raw_get_metadata(self, biotools_reference) -> Optional[str]:
api_url = f"https://bio.tools/api/tool/{biotools_reference}?format=json"
req = requests.get(api_url, timeout=DEFAULT_SOCKET_TIMEOUT)
req.encoding = req.apparent_encoding
if req.status_code == 404:
return None
else:
try:
req = requests.get(api_url, timeout=DEFAULT_SOCKET_TIMEOUT)
req.raise_for_status()
req.encoding = req.apparent_encoding
return req.text
except Exception:
return None

def get_biotools_metadata(self, biotools_reference: str) -> Optional[BiotoolsEntry]:
createfunc = functools.partial(self._raw_get_metadata, biotools_reference)
Expand Down

0 comments on commit 1b0b82f

Please sign in to comment.