aioamazondevices 3.1.3__tar.gz → 3.1.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.
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/PKG-INFO +1 -2
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/pyproject.toml +1 -2
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/src/aioamazondevices/__init__.py +1 -1
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/src/aioamazondevices/api.py +22 -14
- aioamazondevices-3.1.5/src/aioamazondevices/exceptions.py +27 -0
- aioamazondevices-3.1.3/src/aioamazondevices/exceptions.py +0 -55
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/LICENSE +0 -0
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/README.md +0 -0
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/src/aioamazondevices/const.py +0 -0
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/src/aioamazondevices/py.typed +0 -0
- {aioamazondevices-3.1.3 → aioamazondevices-3.1.5}/src/aioamazondevices/sounds.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: aioamazondevices
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.5
|
4
4
|
Summary: Python library to control Amazon devices
|
5
5
|
License: Apache-2.0
|
6
6
|
Author: Simone Chemelli
|
@@ -19,7 +19,6 @@ Requires-Dist: aiohttp
|
|
19
19
|
Requires-Dist: babel
|
20
20
|
Requires-Dist: beautifulsoup4
|
21
21
|
Requires-Dist: colorlog
|
22
|
-
Requires-Dist: httpx
|
23
22
|
Requires-Dist: orjson
|
24
23
|
Requires-Dist: yarl
|
25
24
|
Project-URL: Bug Tracker, https://github.com/chemelli74/aioamazondevices/issues
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "aioamazondevices"
|
3
|
-
version = "3.1.
|
3
|
+
version = "3.1.5"
|
4
4
|
description = "Python library to control Amazon devices"
|
5
5
|
authors = ["Simone Chemelli <simone.chemelli@gmail.com>"]
|
6
6
|
license = "Apache-2.0"
|
@@ -23,7 +23,6 @@ packages = [
|
|
23
23
|
|
24
24
|
[tool.poetry.dependencies]
|
25
25
|
aiohttp = "*"
|
26
|
-
httpx = "*"
|
27
26
|
python = "^3.12"
|
28
27
|
babel = "*"
|
29
28
|
beautifulsoup4 = "*"
|
@@ -15,7 +15,7 @@ from typing import Any, cast
|
|
15
15
|
from urllib.parse import parse_qs, urlencode
|
16
16
|
|
17
17
|
import orjson
|
18
|
-
from aiohttp import ClientResponse, ClientSession
|
18
|
+
from aiohttp import ClientConnectorError, ClientResponse, ClientSession
|
19
19
|
from babel import Locale
|
20
20
|
from bs4 import BeautifulSoup, Tag
|
21
21
|
from multidict import CIMultiDictProxy, MultiDictProxy
|
@@ -52,8 +52,9 @@ from .const import (
|
|
52
52
|
)
|
53
53
|
from .exceptions import (
|
54
54
|
CannotAuthenticate,
|
55
|
+
CannotConnect,
|
55
56
|
CannotRegisterDevice,
|
56
|
-
|
57
|
+
CannotRetrieveData,
|
57
58
|
WrongMethod,
|
58
59
|
)
|
59
60
|
|
@@ -328,13 +329,17 @@ class AmazonEchoApi:
|
|
328
329
|
_cookies = (
|
329
330
|
self._load_website_cookies() if self._login_stored_data else self._cookies
|
330
331
|
)
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
332
|
+
try:
|
333
|
+
resp = await self.session.request(
|
334
|
+
method,
|
335
|
+
URL(url, encoded=True),
|
336
|
+
data=input_data if not json_data else orjson.dumps(input_data),
|
337
|
+
cookies=_cookies,
|
338
|
+
headers=headers,
|
339
|
+
)
|
340
|
+
except (TimeoutError, ClientConnectorError) as exc:
|
341
|
+
raise CannotConnect(f"Connection error during {method}") from exc
|
342
|
+
|
338
343
|
self._cookies.update(**await self._parse_cookies_from_headers(resp.headers))
|
339
344
|
|
340
345
|
content_type: str = resp.headers.get("Content-Type", "")
|
@@ -351,9 +356,11 @@ class AmazonEchoApi:
|
|
351
356
|
HTTPStatus.PROXY_AUTHENTICATION_REQUIRED,
|
352
357
|
HTTPStatus.UNAUTHORIZED,
|
353
358
|
]:
|
354
|
-
raise CannotAuthenticate
|
355
|
-
if not self._ignore_ap_sigin_error(resp):
|
356
|
-
raise
|
359
|
+
raise CannotAuthenticate(HTTPStatus(resp.status).phrase)
|
360
|
+
if not await self._ignore_ap_sigin_error(resp):
|
361
|
+
raise CannotRetrieveData(
|
362
|
+
f"Request failed: {HTTPStatus(resp.status).phrase}"
|
363
|
+
)
|
357
364
|
|
358
365
|
await self._save_to_file(
|
359
366
|
await resp.text(),
|
@@ -457,12 +464,13 @@ class AmazonEchoApi:
|
|
457
464
|
resp_json = await resp.json()
|
458
465
|
|
459
466
|
if resp.status != HTTPStatus.OK:
|
467
|
+
msg = resp_json["response"]["error"]["message"]
|
460
468
|
_LOGGER.error(
|
461
469
|
"Cannot register device for %s: %s",
|
462
470
|
self._login_email,
|
463
|
-
|
471
|
+
msg,
|
464
472
|
)
|
465
|
-
raise CannotRegisterDevice(
|
473
|
+
raise CannotRegisterDevice(f"{HTTPStatus(resp.status).phrase}: {msg}")
|
466
474
|
|
467
475
|
await self._save_to_file(
|
468
476
|
await resp.text(),
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"""Comelit SimpleHome library exceptions."""
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
|
6
|
+
class AmazonError(Exception):
|
7
|
+
"""Base class for aioamazondevices errors."""
|
8
|
+
|
9
|
+
|
10
|
+
class CannotConnect(AmazonError):
|
11
|
+
"""Exception raised when connection fails."""
|
12
|
+
|
13
|
+
|
14
|
+
class CannotAuthenticate(AmazonError):
|
15
|
+
"""Exception raised when credentials are incorrect."""
|
16
|
+
|
17
|
+
|
18
|
+
class CannotRetrieveData(AmazonError):
|
19
|
+
"""Exception raised when data retrieval fails."""
|
20
|
+
|
21
|
+
|
22
|
+
class CannotRegisterDevice(AmazonError):
|
23
|
+
"""Exception raised when device registration fails."""
|
24
|
+
|
25
|
+
|
26
|
+
class WrongMethod(AmazonError):
|
27
|
+
"""Exception raised when the wrong login metho is used."""
|
@@ -1,55 +0,0 @@
|
|
1
|
-
"""Comelit SimpleHome library exceptions."""
|
2
|
-
|
3
|
-
from __future__ import annotations
|
4
|
-
|
5
|
-
|
6
|
-
class AmazonError(Exception):
|
7
|
-
"""Base class for aioamazondevices errors."""
|
8
|
-
|
9
|
-
|
10
|
-
class CannotConnect(AmazonError):
|
11
|
-
"""Exception raised when connection fails."""
|
12
|
-
|
13
|
-
|
14
|
-
class CannotAuthenticate(AmazonError):
|
15
|
-
"""Exception raised when credentials are incorrect."""
|
16
|
-
|
17
|
-
|
18
|
-
class CannotRetrieveData(AmazonError):
|
19
|
-
"""Exception raised when data retrieval fails."""
|
20
|
-
|
21
|
-
|
22
|
-
class CannotRegisterDevice(AmazonError):
|
23
|
-
"""Exception raised when device registration fails."""
|
24
|
-
|
25
|
-
|
26
|
-
class RequestFailed(AmazonError):
|
27
|
-
"""Exception raised when a request fails."""
|
28
|
-
|
29
|
-
|
30
|
-
class WrongMethod(AmazonError):
|
31
|
-
"""Exception raised when the wrong login metho is used."""
|
32
|
-
|
33
|
-
|
34
|
-
class AuthFlowError(AmazonError):
|
35
|
-
"""Exception raised when auth flow fails."""
|
36
|
-
|
37
|
-
|
38
|
-
class AuthMissingTimestamp(AmazonError):
|
39
|
-
"""Exception raised when expires timestamp is missing."""
|
40
|
-
|
41
|
-
|
42
|
-
class AuthMissingAccessToken(AmazonError):
|
43
|
-
"""Exception raised when access token is missing."""
|
44
|
-
|
45
|
-
|
46
|
-
class AuthMissingRefreshToken(AmazonError):
|
47
|
-
"""Exception raised when refresh token is missing."""
|
48
|
-
|
49
|
-
|
50
|
-
class AuthMissingSigningData(AmazonError):
|
51
|
-
"""Exception raised when some data for signing are missing."""
|
52
|
-
|
53
|
-
|
54
|
-
class AuthMissingWebsiteCookies(AmazonError):
|
55
|
-
"""Exception raised when website cookies are missing."""
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|