Skip to content

Commit aebd470

Browse files
committed
ADD: Add platform information to user agent
1 parent 2eed532 commit aebd470

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.37.1 - TBD
4+
5+
#### Enhancements
6+
- Added platform information to the user agent reported by the `Historical` and `Live` clients
7+
38
## 0.37.0 - 2024-07-09
49

510
#### Enhancements

databento/common/system.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
import sys
1+
import platform
2+
import re
3+
from typing import Final
24

35
from databento.version import __version__
46

57

6-
PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
7-
USER_AGENT = f"Databento/{__version__} Python/{PYTHON_VERSION}"
8+
TOKEN_PATTERN: Final = re.compile(r"[^a-zA-Z0-9\.]")
9+
10+
PLATFORM_NAME: Final = TOKEN_PATTERN.sub("-", platform.system())
11+
PLATFORM_VERSION: Final = TOKEN_PATTERN.sub("-", platform.release())
12+
PYTHON_VERSION: Final = TOKEN_PATTERN.sub("-", platform.python_version())
13+
14+
USER_AGENT: Final = (
15+
f"Databento/{__version__} Python/{PYTHON_VERSION} {PLATFORM_NAME}/{PLATFORM_VERSION}"
16+
)

0 commit comments

Comments
 (0)