Skip to content

Commit 77525ba

Browse files
author
Bruno Vieira
committed
add a custom user agent header to requests
Signed-off-by: Bruno Vieira <[email protected]>
1 parent a60484c commit 77525ba

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

chartmogul/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from .api.tags import Tags
1717
from .api.transaction import Transaction
1818

19+
from .version import __version__
20+
1921
# Deprecated
2022
import imp
2123

@@ -25,13 +27,12 @@
2527
2628
Provides convenient Python bindings for ChartMogul's API.
2729
28-
:copyright: (c) 2019 by ChartMogul Ltd.
30+
:copyright: (c) 2023 by ChartMogul Ltd.
2931
:license: MIT, see LICENSE for more details.
3032
"""
3133

3234
__title__ = 'chartmogul'
33-
__version__ = '1.5.0'
3435
__build__ = 0x000000
3536
__author__ = 'ChartMogul Ltd'
3637
__license__ = 'MIT'
37-
__copyright__ = 'Copyright 2020 ChartMogul Ltd'
38+
__copyright__ = 'Copyright 2023 ChartMogul Ltd'

chartmogul/resource.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .api.config import Config
1010
from .errors import APIError, ArgumentMissingError, ConfigurationError, annotateHTTPError
1111
from .retry_request import requests_retry_session
12+
from .version import __version__
1213

1314
"""
1415
HTTP verb mapping. Based on nodejs library.
@@ -132,7 +133,10 @@ def _request(cls, config, method, http_verb, path, data=None, **kwargs):
132133
resolve(getattr(requests_retry_session(config.max_retries, config.backoff_factor), http_verb)(
133134
config.uri + path,
134135
data=data,
135-
headers={'content-type': 'application/json'},
136+
headers={
137+
'content-type': 'application/json',
138+
'User-Agent': 'chartmogul-python/' + __version__
139+
},
136140
params=params,
137141
auth=config.auth,
138142
timeout=config.request_timeout)

chartmogul/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '1.5.1'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'wrapt>=1.11.2'
3535
]
3636

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

0 commit comments

Comments
 (0)