From c41b0dbc50572d96ecc4cb2298a887f6fcbd5daa Mon Sep 17 00:00:00 2001 From: Luca Fabbri Date: Tue, 28 Feb 2023 16:58:14 +0100 Subject: Replaced default python-requests user-agent with a custom ones (#54) * Replaced default python-requests user-agent with a custom ones This can improve analytics and QOS a bit * isort * made black happy --- cdsapi/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cdsapi/api.py b/cdsapi/api.py index 68befdb..0211856 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -14,6 +14,7 @@ import os import time import uuid +import pkg_resources import requests try: @@ -324,6 +325,11 @@ class Client(object): self.session = session self.session.auth = tuple(self.key.split(":", 2)) + self.session.headers = { + "User-Agent": "cdsapi/%s" + % pkg_resources.get_distribution("cdsapi").version, + } + assert len(self.session.auth) == 2, ( "The cdsapi key provided is not the correct format, please ensure it conforms to:\n" ":" -- cgit v1.2.3