Skip to content

Commit

Permalink
abi3audit: set user-agent (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw authored Nov 18, 2024
1 parent b45c880 commit 93fa9ac
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions abi3audit/_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from packaging.tags import Tag

import abi3audit._object as _object
from abi3audit import __version__
from abi3audit._cache import caching_session
from abi3audit._state import console, status

Expand Down Expand Up @@ -216,14 +217,15 @@ def __init__(self, spec: PyPISpec) -> None:
self.spec = spec
self.parent = None
self._session = caching_session()
self._session.headers.update(
{"Accept-Encoding": "gzip", "User-Agent": f"abi3audit/{__version__}"}
)

def __iter__(self) -> Iterator[_object.SharedObject]:
status.update(f"{self}: querying PyPI")

# TODO: Error handling for this request.
resp = self._session.get(
f"https://pypi.org/pypi/{self.spec}/json", headers={"Accept-Encoding": "gzip"}
)
resp = self._session.get(f"https://pypi.org/pypi/{self.spec}/json")

if not resp.ok:
console.log(f"[red]:skull: {self}: PyPI returned {resp.status_code}")
Expand Down

0 comments on commit 93fa9ac

Please sign in to comment.