Skip to content

Commit 1422044

Browse files
committed
Change logging to debug
1 parent fb99e0e commit 1422044

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# 1.0.2
1+
# 1.0.3
2+
3+
* Change logging to debug
24

3-
### Bugfixes
5+
# 1.0.2
46

57
* username and password changed to mandatory arguments
68
* Make dataclasses subscriptable
79

810
# 1.0.1
911

10-
### Bugfixes
11-
1212
* Fix login and get_status not raising InvalidAuth when unauthorized
1313

1414
# 1.0.0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = PyLoadAPI
3-
version = 1.0.2
3+
version = 1.0.3
44
author = Manfred Dennerlein Rodelo
55
author_email = [email protected]
66
description = "Simple wrapper for pyLoad's API."

src/pyloadapi/api.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,32 @@ async def login(self) -> LoginResponse:
3636
url = f"{self.api_url}api/login"
3737
try:
3838
async with self._session.post(url, data=user_data) as r:
39-
_LOGGER.debug(
40-
"Response from %s [%s]: %s", url, r.status, (await r.text())
41-
)
39+
_LOGGER.debug("Response from %s [%s]: %s", url, r.status, r.text)
40+
4241
r.raise_for_status()
4342
try:
4443
data = await r.json()
4544
if not data:
4645
raise InvalidAuth
4746
return LoginResponse.from_dict(data)
4847
except JSONDecodeError as e:
49-
_LOGGER.error(
48+
_LOGGER.debug(
5049
"Exception: Cannot parse login response:\n %s",
5150
traceback.format_exc(),
5251
)
5352
raise ParserError(
5453
"Login failed during parsing of request response."
5554
) from e
5655
except (TimeoutError, aiohttp.ClientError) as e:
57-
_LOGGER.error("Exception: Cannot login:\n %s", traceback.format_exc())
56+
_LOGGER.debug("Exception: Cannot login:\n %s", traceback.format_exc())
5857
raise CannotConnect from e
5958

6059
async def get_status(self) -> StatusServerResponse:
6160
"""Get general status information of pyLoad."""
6261
url = f"{self.api_url}api/statusServer"
6362
try:
6463
async with self._session.get(url) as r:
65-
_LOGGER.debug(
66-
"Response from %s [%s]: %s", url, r.status, (await r.text())
67-
)
64+
_LOGGER.debug("Response from %s [%s]: %s", url, r.status, r.text)
6865

6966
if r.status == HTTPStatus.UNAUTHORIZED:
7067
raise InvalidAuth
@@ -73,7 +70,7 @@ async def get_status(self) -> StatusServerResponse:
7370
data = await r.json()
7471
return StatusServerResponse.from_dict(data)
7572
except JSONDecodeError as e:
76-
_LOGGER.error(
73+
_LOGGER.debug(
7774
"Exception: Cannot parse status response:\n %s",
7875
traceback.format_exc(),
7976
)
@@ -82,31 +79,29 @@ async def get_status(self) -> StatusServerResponse:
8279
) from e
8380

8481
except (TimeoutError, aiohttp.ClientError) as e:
85-
_LOGGER.error("Exception: Cannot get status:\n %s", traceback.format_exc())
82+
_LOGGER.debug("Exception: Cannot get status:\n %s", traceback.format_exc())
8683
raise CannotConnect("Get status failed due to request exception") from e
8784

8885
async def version(self) -> str:
8986
"""Get version of pyLoad."""
9087
url = f"{self.api_url}api/getServerVersion"
9188
try:
9289
async with self._session.get(url) as r:
93-
_LOGGER.debug(
94-
"Response from %s [%s]: %s", url, r.status, (await r.text())
95-
)
90+
_LOGGER.debug("Response from %s [%s]: %s", url, r.status, r.text)
9691
if r.status == HTTPStatus.UNAUTHORIZED:
9792
raise InvalidAuth
9893
r.raise_for_status()
9994
try:
10095
data = await r.json()
10196
return str(data)
10297
except JSONDecodeError as e:
103-
_LOGGER.error(
98+
_LOGGER.debug(
10499
"Exception: Cannot parse status response:\n %s",
105100
traceback.format_exc(),
106101
)
107102
raise ParserError(
108103
"Get version failed during parsing of request response."
109104
) from e
110105
except (TimeoutError, aiohttp.ClientError) as e:
111-
_LOGGER.error("Exception: Cannot get version:\n %s", traceback.format_exc())
106+
_LOGGER.debug("Exception: Cannot get version:\n %s", traceback.format_exc())
112107
raise CannotConnect("Get version failed due to request exception") from e

0 commit comments

Comments
 (0)