Skip to content

Commit 76c4c13

Browse files
author
github-actions[bot]
committed
# base.py
- Changed format of debug logger statements. - Fixed logic handling for closed sessions and attempting to re-create a ClientSession(). # instance.py - Removed unneeded debug print in it's init.
1 parent b29f8c4 commit 76c4c13

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

ampapi/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
__title__ = "CubeCoders AMP API"
2626
__author__ = "k8thekat"
2727
__license__ = "GNU"
28-
__version__ = "4.5.1"
28+
__version__ = "4.5.2"
2929
__credits__ = "AMP by CubeCoders and associates."
3030

3131
from typing import Literal, NamedTuple
@@ -55,6 +55,6 @@ class VersionInfo(NamedTuple):
5555
releaseLevel: Literal["alpha", "beta", "pre-release", "release", "development"]
5656

5757

58-
version_info: VersionInfo = VersionInfo(Major=4, Minor=5, Revision=1, releaseLevel="development")
58+
version_info: VersionInfo = VersionInfo(Major=4, Minor=5, Revision=2, releaseLevel="development")
5959

6060
del NamedTuple, Literal, VersionInfo

ampapi/base.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ async def _call_api(
270270
except RuntimeError as e:
271271
# ? Suggestion
272272
# Attempting to re-open the session if it is somehow closed during usage.
273-
if "session is closed" in e.args[0].lower():
273+
if isinstance(e.args[0], str) and "session is closed" in e.args[0].lower():
274274
self.session = aiohttp.ClientSession()
275275

276276
retry: float = self._backoff.delay()
277-
self.logger.error("Runtime Error, will retry in %s. | Exception: %s", retry, exc_info=e)
277+
self.logger.error("Runtime Error, will retry in %s. | Exception: %s", retry, e)
278278
await asyncio.sleep(delay=retry)
279279
return await self._call_api(
280280
api=api,
@@ -316,11 +316,16 @@ async def _call_api(
316316
# They removed "result" from all replies thus breaking most if not all future code.
317317
# This was an old example from pre 2.3 AMP API that could have the following return:
318318
# `{'resultReason': 'Internal Auth - No reason given', 'success': False, 'result': 0}`
319-
self.logger.debug("RESPONSE JSON %s | REQ JSON TYPE: %s | PARAMETERS: %s", api, type(post_req_json), parameters)
320-
self.logger.debug("DEBUG RESPONSE: %s", pformat(post_req_json))
319+
self.logger.debug(
320+
"URL: %s | aiohttp.ClientResponse.json() type: %s | _call_api parameters: %s",
321+
api,
322+
type(post_req_json),
323+
parameters,
324+
)
325+
self.logger.debug("aiohttp.ClientResponse.json() formatted: %s", pformat(post_req_json))
321326
if sanitize_json is True:
322327
post_req_json = self.sanitize_json(post_req_json)
323-
self.logger.debug("DEBUG RESPONSE SANITIZED: %s", pformat(post_req_json))
328+
self.logger.debug("Sanitize json: %s | Sanitized data: %s", sanitize_json, pformat(post_req_json))
324329

325330
if isinstance(post_req_json, dict):
326331
if "title" in post_req_json:

ampapi/instance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class AMPInstance(
118118
def __init__(
119119
self, data: Union[Instance, None], controller: Union[AMPControllerInstance, None] = None, **kwargs: Any
120120
) -> None:
121-
self.logger.debug("DEBUG %s __init__ %s", type(self).__name__, id(self))
121+
# self.logger.debug("DEBUG %s __init__ %s", type(self).__name__, id(self))
122122
super().__init__(**kwargs)
123123

124124
if isinstance(data, Instance):

0 commit comments

Comments
 (0)