wherobots-python-dbapi 0.7.3__tar.gz → 0.7.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wherobots-python-dbapi
3
- Version: 0.7.3
3
+ Version: 0.7.5
4
4
  Summary: Python DB-API driver for Wherobots DB
5
5
  License: Apache 2.0
6
6
  Author: Maxime Petazzoni
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "wherobots-python-dbapi"
3
- version = "0.7.3"
3
+ version = "0.7.5"
4
4
  description = "Python DB-API driver for Wherobots DB"
5
5
  authors = ["Maxime Petazzoni <max@wherobots.com>"]
6
6
  license = "Apache 2.0"
@@ -4,9 +4,12 @@ A PEP-0249 compatible driver for interfacing with Wherobots DB.
4
4
  """
5
5
 
6
6
  import logging
7
- import os
7
+ import platform
8
8
  import urllib.parse
9
9
  import queue
10
+ from importlib import metadata
11
+ from importlib.metadata import PackageNotFoundError
12
+
10
13
  import requests
11
14
  import tenacity
12
15
  import threading
@@ -39,6 +42,18 @@ threadsafety = 1
39
42
  paramstyle = "pyformat"
40
43
 
41
44
 
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
+
42
57
  def connect(
43
58
  host: str = DEFAULT_ENDPOINT,
44
59
  token: str = None,
@@ -57,7 +72,7 @@ def connect(
57
72
  if token and api_key:
58
73
  raise ValueError("`token` and `api_key` can't be both provided")
59
74
 
60
- headers = {}
75
+ headers = gen_user_agent_header()
61
76
  if token:
62
77
  headers["Authorization"] = f"Bearer {token}"
63
78
  elif api_key:
@@ -2,12 +2,12 @@ from enum import Enum
2
2
 
3
3
 
4
4
  class 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"
11
11
  ATLANTIS = "4x-large"
12
12
 
13
13
  NEW_YORK_HIMEM = "medium-himem"