python-aidot 0.3.51__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.51 → python_aidot-0.3.52}/PKG-INFO +1 -1
- {python_aidot-0.3.51 → python_aidot-0.3.52}/aidot/client.py +11 -11
- {python_aidot-0.3.51 → python_aidot-0.3.52}/aidot/const.py +1 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/aidot/login_const.py +5 -2
- {python_aidot-0.3.51 → python_aidot-0.3.52}/python_aidot.egg-info/PKG-INFO +1 -1
- {python_aidot-0.3.51 → python_aidot-0.3.52}/setup.py +1 -1
- {python_aidot-0.3.51 → python_aidot-0.3.52}/LICENSE +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/README.md +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/aidot/__init__.py +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/aidot/aes_utils.py +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/aidot/device_client.py +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/aidot/discover.py +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/aidot/exceptions.py +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/python_aidot.egg-info/SOURCES.txt +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/python_aidot.egg-info/dependency_links.txt +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/python_aidot.egg-info/requires.txt +0 -0
- {python_aidot-0.3.51 → python_aidot-0.3.52}/python_aidot.egg-info/top_level.txt +0 -0
- {python_aidot-0.3.51 → 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
|
|
@@ -153,7 +153,7 @@ class AidotClient:
|
|
|
153
153
|
self.setup_discover()
|
|
154
154
|
return self.login_info
|
|
155
155
|
except aiohttp.ClientError as e:
|
|
156
|
-
_LOGGER.
|
|
156
|
+
_LOGGER.error(f"async_post_login ClientError: {e}")
|
|
157
157
|
if response_data[CONF_CODE] == ServerErrorCode.USER_PWD_INCORRECT:
|
|
158
158
|
raise AidotUserOrPassIncorrect
|
|
159
159
|
raise Exception
|
|
@@ -172,12 +172,12 @@ class AidotClient:
|
|
|
172
172
|
self.login_info[CONF_ACCESS_TOKEN] = response_data[CONF_ACCESS_TOKEN]
|
|
173
173
|
if response_data[CONF_REFRESH_TOKEN] is not None:
|
|
174
174
|
self.login_info[CONF_REFRESH_TOKEN] = response_data[CONF_REFRESH_TOKEN]
|
|
175
|
-
_LOGGER.
|
|
175
|
+
_LOGGER.debug(f"refresh token: {response_data}")
|
|
176
176
|
if self._token_fresh_cb:
|
|
177
177
|
self._token_fresh_cb()
|
|
178
178
|
return response_data
|
|
179
179
|
except aiohttp.ClientError as e:
|
|
180
|
-
_LOGGER.
|
|
180
|
+
_LOGGER.error(f"async_refresh_token ClientError: {e} {response_data}")
|
|
181
181
|
if response_data[CONF_CODE] == ServerErrorCode.LOGIN_INVALID:
|
|
182
182
|
raise AidotAuthFailed
|
|
183
183
|
return None
|
|
@@ -202,7 +202,7 @@ class AidotClient:
|
|
|
202
202
|
response.raise_for_status()
|
|
203
203
|
return response_data
|
|
204
204
|
except aiohttp.ClientError as e:
|
|
205
|
-
_LOGGER.
|
|
205
|
+
_LOGGER.error(f"async_get ClientError: {e} {response_data}")
|
|
206
206
|
code = response_data.get(CONF_CODE)
|
|
207
207
|
if code == ServerErrorCode.TOKEN_EXPIRED:
|
|
208
208
|
try:
|
|
@@ -300,5 +300,5 @@ class AidotClient:
|
|
|
300
300
|
|
|
301
301
|
async def async_cleanup(self) -> None:
|
|
302
302
|
"""清理所有资源"""
|
|
303
|
-
_LOGGER.
|
|
303
|
+
_LOGGER.debug("async_cleanup")
|
|
304
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
|