File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 11[tool .poetry ]
22name = " wherobots-python-dbapi"
3- version = " 0.7.3 "
3+ version = " 0.7.4 "
44description = " Python DB-API driver for Wherobots DB"
55authors = [
" Maxime Petazzoni <[email protected] >" ]
66license = " Apache 2.0"
Original file line number Diff line number Diff line change 44"""
55
66import logging
7- import os
7+ import platform
88import urllib .parse
99import queue
10+ from importlib import metadata
11+ from importlib .metadata import PackageNotFoundError
12+
1013import requests
1114import tenacity
1215import threading
3942paramstyle = "pyformat"
4043
4144
45+ def gen_user_agent_header ():
46+ try :
47+ package_version = metadata .version ("wherobots-python-dbapi" )
48+ except PackageNotFoundError :
49+ package_version = "unknown"
50+ python_version = platform .python_version ()
51+ system = platform .system ().lower ()
52+ return {
53+ "User-Agent" : f"wherobots-python-dbapi/{ package_version } os/{ system } python/{ python_version } "
54+ }
55+
56+
4257def connect (
4358 host : str = DEFAULT_ENDPOINT ,
4459 token : str = None ,
@@ -57,12 +72,14 @@ def connect(
5772 if token and api_key :
5873 raise ValueError ("`token` and `api_key` can't be both provided" )
5974
60- headers = {}
75+ headers = gen_user_agent_header ()
6176 if token :
6277 headers ["Authorization" ] = f"Bearer { token } "
6378 elif api_key :
6479 headers ["X-API-Key" ] = api_key
6580
81+ logging .info (headers )
82+
6683 host = host or DEFAULT_ENDPOINT
6784 runtime = runtime or DEFAULT_RUNTIME
6885 region = region or DEFAULT_REGION
Original file line number Diff line number Diff line change 22
33
44class Runtime (Enum ):
5- SEDONA = "TINY "
6- SAN_FRANCISCO = "SMALL "
7- NEW_YORK = "MEDIUM "
8- CAIRO = "LARGE "
9- DELHI = "XLARGE "
10- TOKYO = "XXLARGE "
5+ SEDONA = "tiny "
6+ SAN_FRANCISCO = "small "
7+ NEW_YORK = "medium "
8+ CAIRO = "large "
9+ DELHI = "x-large "
10+ TOKYO = "2x-large "
1111 ATLANTIS = "4x-large"
1212
1313 NEW_YORK_HIMEM = "medium-himem"
You can’t perform that action at this time.
0 commit comments