Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report dandi version in User-Agent header #424

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dandi/dandiapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .consts import MAX_CHUNK_SIZE, known_instances_rev
from .girder import keyring_lookup
from . import get_logger
from .utils import USER_AGENT

lgr = get_logger()

Expand All @@ -21,7 +22,7 @@ class RESTFullAPIClient(object):
def __init__(self, api_url):
self.api_url = api_url
self._session = None
self._headers = {}
self._headers = {"User-Agent": USER_AGENT}

@contextmanager
def session(self, session=None):
Expand Down
7 changes: 7 additions & 0 deletions dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
and os.environ.get("MSYSTEM", "")[:4] in ("MSYS", "MING")
)

USER_AGENT = "dandi/{} requests/{} {}/{}".format(
__version__,
requests.__version__,
platform.python_implementation(),
platform.python_version(),
)


def is_interactive():
"""Return True if all in/outs are tty"""
Expand Down