python-aidot 0.3.50__tar.gz → 0.3.52__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.
- {python_aidot-0.3.50 → python_aidot-0.3.52}/PKG-INFO +1 -1
- {python_aidot-0.3.50 → python_aidot-0.3.52}/aidot/client.py +21 -18
- {python_aidot-0.3.50 → python_aidot-0.3.52}/aidot/const.py +1 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/aidot/login_const.py +5 -2
- {python_aidot-0.3.50 → python_aidot-0.3.52}/python_aidot.egg-info/PKG-INFO +1 -1
- {python_aidot-0.3.50 → python_aidot-0.3.52}/setup.py +1 -1
- {python_aidot-0.3.50 → python_aidot-0.3.52}/LICENSE +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/README.md +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/aidot/__init__.py +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/aidot/aes_utils.py +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/aidot/device_client.py +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/aidot/discover.py +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/aidot/exceptions.py +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/python_aidot.egg-info/SOURCES.txt +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/python_aidot.egg-info/dependency_links.txt +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/python_aidot.egg-info/requires.txt +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/python_aidot.egg-info/top_level.txt +0 -0
- {python_aidot-0.3.50 → python_aidot-0.3.52}/setup.cfg +0 -0
|
@@ -15,7 +15,7 @@ import hashlib
|
|
|
15
15
|
from .exceptions import AidotAuthFailed, AidotUserOrPassIncorrect
|
|
16
16
|
from .device_client import DeviceClient
|
|
17
17
|
from .discover import Discover
|
|
18
|
-
from .login_const import APP_ID, PUBLIC_KEY_PEM,
|
|
18
|
+
from .login_const import APP_ID, PUBLIC_KEY_PEM, API_URL_TEMPLATE, DEFAULT_REGION
|
|
19
19
|
from .const import (
|
|
20
20
|
CONF_ACCESS_TOKEN,
|
|
21
21
|
CONF_APP_ID,
|
|
@@ -58,8 +58,8 @@ def rsa_password_encrypt(message: str) -> str:
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
class AidotClient:
|
|
61
|
-
_base_url: str =
|
|
62
|
-
_region: str =
|
|
61
|
+
_base_url: str = API_URL_TEMPLATE.format(region=DEFAULT_REGION)
|
|
62
|
+
_region: str = DEFAULT_REGION
|
|
63
63
|
session: Optional[ClientSession] = None
|
|
64
64
|
username: str = ""
|
|
65
65
|
password: str = ""
|
|
@@ -77,7 +77,7 @@ class AidotClient:
|
|
|
77
77
|
password: str | None = None,
|
|
78
78
|
token: dict | None = None,
|
|
79
79
|
) -> None:
|
|
80
|
-
_LOGGER.
|
|
80
|
+
_LOGGER.info("Client Version: v0.3.52")
|
|
81
81
|
self.session = session
|
|
82
82
|
self.username = username
|
|
83
83
|
self.password = password
|
|
@@ -87,7 +87,7 @@ class AidotClient:
|
|
|
87
87
|
if item["id"] == self.country_code:
|
|
88
88
|
self.country_name = item["name"]
|
|
89
89
|
self._region = item["region"].lower()
|
|
90
|
-
self._base_url =
|
|
90
|
+
self._base_url = API_URL_TEMPLATE.format(region=self._region)
|
|
91
91
|
break
|
|
92
92
|
if token is not None:
|
|
93
93
|
self.login_info = token.copy()
|
|
@@ -95,7 +95,7 @@ class AidotClient:
|
|
|
95
95
|
self.password = token[CONF_PASSWORD]
|
|
96
96
|
self._region = token[CONF_REGION]
|
|
97
97
|
self.country_name = token[CONF_COUNTRY]
|
|
98
|
-
self._base_url =
|
|
98
|
+
self._base_url = API_URL_TEMPLATE.format(region=self._region)
|
|
99
99
|
self.setup_discover()
|
|
100
100
|
def set_token_fresh_cb(self, callback) -> None:
|
|
101
101
|
self._token_fresh_cb = callback
|
|
@@ -110,13 +110,16 @@ class AidotClient:
|
|
|
110
110
|
file_path = Path.home() / ".aidot_terminal_id"
|
|
111
111
|
|
|
112
112
|
def _read_or_create() -> str:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
try:
|
|
114
|
+
if file_path.exists():
|
|
115
|
+
return file_path.read_text().strip()
|
|
116
|
+
node = uuid.getnode()
|
|
117
|
+
is_random = (node >> 40) & 1
|
|
118
|
+
raw_id = str(uuid.uuid4()) if is_random else format(node, "x")
|
|
119
|
+
file_path.write_text(raw_id)
|
|
120
|
+
return raw_id
|
|
121
|
+
except OSError:
|
|
122
|
+
return 'gvz3gjae10l4zii00t7y0'
|
|
120
123
|
|
|
121
124
|
raw_id = await asyncio.to_thread(_read_or_create)
|
|
122
125
|
return hashlib.md5(raw_id.encode()).hexdigest()
|
|
@@ -150,7 +153,7 @@ class AidotClient:
|
|
|
150
153
|
self.setup_discover()
|
|
151
154
|
return self.login_info
|
|
152
155
|
except aiohttp.ClientError as e:
|
|
153
|
-
_LOGGER.
|
|
156
|
+
_LOGGER.error(f"async_post_login ClientError: {e}")
|
|
154
157
|
if response_data[CONF_CODE] == ServerErrorCode.USER_PWD_INCORRECT:
|
|
155
158
|
raise AidotUserOrPassIncorrect
|
|
156
159
|
raise Exception
|
|
@@ -169,12 +172,12 @@ class AidotClient:
|
|
|
169
172
|
self.login_info[CONF_ACCESS_TOKEN] = response_data[CONF_ACCESS_TOKEN]
|
|
170
173
|
if response_data[CONF_REFRESH_TOKEN] is not None:
|
|
171
174
|
self.login_info[CONF_REFRESH_TOKEN] = response_data[CONF_REFRESH_TOKEN]
|
|
172
|
-
_LOGGER.
|
|
175
|
+
_LOGGER.debug(f"refresh token: {response_data}")
|
|
173
176
|
if self._token_fresh_cb:
|
|
174
177
|
self._token_fresh_cb()
|
|
175
178
|
return response_data
|
|
176
179
|
except aiohttp.ClientError as e:
|
|
177
|
-
_LOGGER.
|
|
180
|
+
_LOGGER.error(f"async_refresh_token ClientError: {e} {response_data}")
|
|
178
181
|
if response_data[CONF_CODE] == ServerErrorCode.LOGIN_INVALID:
|
|
179
182
|
raise AidotAuthFailed
|
|
180
183
|
return None
|
|
@@ -199,7 +202,7 @@ class AidotClient:
|
|
|
199
202
|
response.raise_for_status()
|
|
200
203
|
return response_data
|
|
201
204
|
except aiohttp.ClientError as e:
|
|
202
|
-
_LOGGER.
|
|
205
|
+
_LOGGER.error(f"async_get ClientError: {e} {response_data}")
|
|
203
206
|
code = response_data.get(CONF_CODE)
|
|
204
207
|
if code == ServerErrorCode.TOKEN_EXPIRED:
|
|
205
208
|
try:
|
|
@@ -297,5 +300,5 @@ class AidotClient:
|
|
|
297
300
|
|
|
298
301
|
async def async_cleanup(self) -> None:
|
|
299
302
|
"""清理所有资源"""
|
|
300
|
-
_LOGGER.
|
|
303
|
+
_LOGGER.debug("async_cleanup")
|
|
301
304
|
await self.async_close()
|
|
@@ -101,6 +101,7 @@ SUPPORTED_COUNTRYS = [
|
|
|
101
101
|
{"_id": "16-4", "id": "PK", "name": "Pakistan", "ext": "", "region": "JP"},
|
|
102
102
|
{"_id": "16-5", "id": "PS", "name": "Palestine", "ext": "", "region": "JP"},
|
|
103
103
|
{"_id": "16-6", "id": "PH", "name": "Philippines", "ext": "", "region": "JP"},
|
|
104
|
+
{"_id": "16-7", "id": "PL", "name": "Poland", "ext": "", "region": "EU"},
|
|
104
105
|
{"_id": "17-0", "id": "QA", "name": "Qatar", "ext": "", "region": "JP"},
|
|
105
106
|
{"_id": "18-0", "id": "RO", "name": "Romania", "ext": "", "region": "EU"},
|
|
106
107
|
{"_id": "18-1", "id": "RU", "name": "Russia", "ext": "", "region": "EU"},
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
"""Constants for the aidot
|
|
1
|
+
"""Constants for the aidot login."""
|
|
2
2
|
|
|
3
3
|
APP_ID = "1383974540041977857"
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
# API URL template - use .format(region="us") to construct
|
|
6
|
+
API_URL_TEMPLATE = "https://prod-{region}-api.arnoo.com/v17"
|
|
7
|
+
DEFAULT_REGION = "us"
|
|
5
8
|
|
|
6
9
|
PUBLIC_KEY_PEM = b"""
|
|
7
10
|
-----BEGIN PUBLIC KEY-----
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|