Skip to content

Commit

Permalink
Allow doi.org API hit to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
vaneseltine committed Jul 13, 2024
1 parent 6db8bd4 commit cc6857d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ash/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,16 @@ def exists(self) -> bool | None:
@classmethod
def _exists_at_api(cls, doi: str) -> bool | None:
url = cls.API_URL.format(doi=doi)
resp = http.request("HEAD", url)
existence = cls.API_RESPONSE_MAP.get(resp.status)
logger.info(f"{doi} | {url} | {resp.status} = {existence}")
logger.info(f"{doi} | {url} | ...")
try:
resp = http.request("HEAD", url)
resp_status = resp.status
existence = cls.API_RESPONSE_MAP.get(resp.status)
except Exception as err: # pylint: disable=broad-exception-caught
logger.info(str(err))
resp_status = "Connection to API failed"
existence = None
logger.info(f"{doi} | {url} | {resp_status} = {existence}")
return existence

@classmethod
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from nox.sessions import Session

CODE_DIR = "ash"

os.environ["PYTHONDONTWRITEBYTECODE"] = "1"
IN_CI = os.getenv("CI", "").lower() == "true"

Expand Down

0 comments on commit cc6857d

Please sign in to comment.