Skip to content

Commit

Permalink
add a custom user agent header to requests
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Vieira <[email protected]>
  • Loading branch information
Bruno Vieira committed Oct 2, 2023
1 parent a60484c commit 77525ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions chartmogul/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from .api.tags import Tags
from .api.transaction import Transaction

from .version import __version__

# Deprecated
import imp

Expand All @@ -25,13 +27,12 @@
Provides convenient Python bindings for ChartMogul's API.
:copyright: (c) 2019 by ChartMogul Ltd.
:copyright: (c) 2023 by ChartMogul Ltd.
:license: MIT, see LICENSE for more details.
"""

__title__ = 'chartmogul'
__version__ = '1.5.0'
__build__ = 0x000000
__author__ = 'ChartMogul Ltd'
__license__ = 'MIT'
__copyright__ = 'Copyright 2020 ChartMogul Ltd'
__copyright__ = 'Copyright 2023 ChartMogul Ltd'
6 changes: 5 additions & 1 deletion chartmogul/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .api.config import Config
from .errors import APIError, ArgumentMissingError, ConfigurationError, annotateHTTPError
from .retry_request import requests_retry_session
from .version import __version__

"""
HTTP verb mapping. Based on nodejs library.
Expand Down Expand Up @@ -132,7 +133,10 @@ def _request(cls, config, method, http_verb, path, data=None, **kwargs):
resolve(getattr(requests_retry_session(config.max_retries, config.backoff_factor), http_verb)(
config.uri + path,
data=data,
headers={'content-type': 'application/json'},
headers={
'content-type': 'application/json',
'User-Agent': 'chartmogul-python/' + __version__
},
params=params,
auth=config.auth,
timeout=config.request_timeout)
Expand Down
1 change: 1 addition & 0 deletions chartmogul/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '1.5.1'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'wrapt>=1.11.2'
]

with open('chartmogul/__init__.py', 'r') as fd:
with open('chartmogul/version.py', 'r') as fd:
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
fd.read(), re.MULTILINE).group(1)

Expand Down

0 comments on commit 77525ba

Please sign in to comment.