Unverified Commit 1b0b82f0 authored by Nicola Soranzo's avatar Nicola Soranzo Committed by GitHub
Browse files

Merge pull request #18510 from...

Merge pull request #18510 from nsoranzo/release_23.2_fix_ApiBiotoolsMetadataSource._raw_get_metadata

[23.2] Handle all requests error in ``ApiBiotoolsMetadataSource._raw_get_metadata``
parents 06590c92 4ac6a1e4
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -54,12 +54,13 @@ class ApiBiotoolsMetadataSource(BiotoolsMetadataSource):

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