pyezvizapi 1.0.3.8__py3-none-any.whl → 1.0.4.0__py3-none-any.whl
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.
Potentially problematic release.
This version of pyezvizapi might be problematic. Click here for more details.
- pyezvizapi/client.py +56 -1
- {pyezvizapi-1.0.3.8.dist-info → pyezvizapi-1.0.4.0.dist-info}/METADATA +1 -1
- {pyezvizapi-1.0.3.8.dist-info → pyezvizapi-1.0.4.0.dist-info}/RECORD +7 -7
- {pyezvizapi-1.0.3.8.dist-info → pyezvizapi-1.0.4.0.dist-info}/WHEEL +0 -0
- {pyezvizapi-1.0.3.8.dist-info → pyezvizapi-1.0.4.0.dist-info}/licenses/LICENSE +0 -0
- {pyezvizapi-1.0.3.8.dist-info → pyezvizapi-1.0.4.0.dist-info}/licenses/LICENSE.md +0 -0
- {pyezvizapi-1.0.3.8.dist-info → pyezvizapi-1.0.4.0.dist-info}/top_level.txt +0 -0
pyezvizapi/client.py
CHANGED
|
@@ -357,6 +357,15 @@ class EzvizClient:
|
|
|
357
357
|
individual endpoint behavior. Returns the Response for the caller to
|
|
358
358
|
parse and validate according to its API contract.
|
|
359
359
|
"""
|
|
360
|
+
if _LOGGER.isEnabledFor(logging.DEBUG):
|
|
361
|
+
_LOGGER.debug(
|
|
362
|
+
"HTTP %s %s params=%s data=%s json=%s",
|
|
363
|
+
method,
|
|
364
|
+
url,
|
|
365
|
+
self._summarize_payload(params),
|
|
366
|
+
self._summarize_payload(data),
|
|
367
|
+
self._summarize_payload(json_body),
|
|
368
|
+
)
|
|
360
369
|
try:
|
|
361
370
|
req = self._session.request(
|
|
362
371
|
method=method,
|
|
@@ -388,6 +397,17 @@ class EzvizClient:
|
|
|
388
397
|
)
|
|
389
398
|
raise HTTPError from err
|
|
390
399
|
else:
|
|
400
|
+
if _LOGGER.isEnabledFor(logging.DEBUG):
|
|
401
|
+
content_length = req.headers.get("Content-Length")
|
|
402
|
+
if content_length is None:
|
|
403
|
+
content_length = str(len(req.content))
|
|
404
|
+
_LOGGER.debug(
|
|
405
|
+
"HTTP %s %s -> %s (%s bytes)",
|
|
406
|
+
method,
|
|
407
|
+
url,
|
|
408
|
+
req.status_code,
|
|
409
|
+
content_length,
|
|
410
|
+
)
|
|
391
411
|
return req
|
|
392
412
|
|
|
393
413
|
@staticmethod
|
|
@@ -466,12 +486,37 @@ class EzvizClient:
|
|
|
466
486
|
return payload.get("status")
|
|
467
487
|
return None
|
|
468
488
|
|
|
489
|
+
@staticmethod
|
|
490
|
+
def _summarize_payload(payload: Any) -> str:
|
|
491
|
+
"""Return a compact description of payload content for debug logs."""
|
|
492
|
+
|
|
493
|
+
if payload is None:
|
|
494
|
+
return "-"
|
|
495
|
+
if isinstance(payload, Mapping):
|
|
496
|
+
keys = ", ".join(sorted(str(key) for key in payload))
|
|
497
|
+
return f"dict[{keys}]"
|
|
498
|
+
if isinstance(payload, (list, tuple, set)):
|
|
499
|
+
return f"{type(payload).__name__}(len={len(payload)})"
|
|
500
|
+
if isinstance(payload, (bytes, bytearray)):
|
|
501
|
+
return f"bytes(len={len(payload)})"
|
|
502
|
+
if isinstance(payload, str):
|
|
503
|
+
trimmed = payload[:32] + "…" if len(payload) > 32 else payload
|
|
504
|
+
return f"str(len={len(payload)}, preview={trimmed!r})"
|
|
505
|
+
return f"{type(payload).__name__}"
|
|
506
|
+
|
|
469
507
|
def _ensure_ok(self, payload: dict, message: str) -> None:
|
|
470
508
|
"""Raise PyEzvizError with context if response is not OK.
|
|
471
509
|
|
|
472
510
|
Accepts both API styles: new (meta.code == 200) and legacy (resultCode == 0).
|
|
473
511
|
"""
|
|
474
512
|
if not self._is_ok(payload):
|
|
513
|
+
if _LOGGER.isEnabledFor(logging.DEBUG):
|
|
514
|
+
_LOGGER.debug(
|
|
515
|
+
"API error detected (%s): code=%s payload=%s",
|
|
516
|
+
message,
|
|
517
|
+
self._response_code(payload),
|
|
518
|
+
json.dumps(payload, ensure_ascii=False),
|
|
519
|
+
)
|
|
475
520
|
raise PyEzvizError(f"{message}: Got {payload})")
|
|
476
521
|
|
|
477
522
|
def _send_prepared(
|
|
@@ -530,7 +575,17 @@ class EzvizClient:
|
|
|
530
575
|
retry_401=retry_401,
|
|
531
576
|
max_retries=max_retries,
|
|
532
577
|
)
|
|
533
|
-
|
|
578
|
+
payload = self._parse_json(resp)
|
|
579
|
+
if _LOGGER.isEnabledFor(logging.DEBUG):
|
|
580
|
+
_LOGGER.debug(
|
|
581
|
+
"JSON %s %s -> status=%s meta=%s keys=%s",
|
|
582
|
+
method,
|
|
583
|
+
path,
|
|
584
|
+
resp.status_code,
|
|
585
|
+
self._response_code(payload),
|
|
586
|
+
", ".join(sorted(payload.keys())),
|
|
587
|
+
)
|
|
588
|
+
return payload
|
|
534
589
|
|
|
535
590
|
def _retry_json(
|
|
536
591
|
self,
|
|
@@ -3,7 +3,7 @@ pyezvizapi/__main__.py,sha256=6vFvkh8gCD-Mo4CXd1deZfDeaaHR-Kc8pOu9vkUjQf4,20878
|
|
|
3
3
|
pyezvizapi/api_endpoints.py,sha256=2M5Vs4YB1VWZGcowT-4Fj2hhRNjFh976LT3jtRrqvrc,5754
|
|
4
4
|
pyezvizapi/camera.py,sha256=Pl5oIEdrFcv1Hz5sQI1IyyJIDCMjOjQdtExgKzmLoK8,22102
|
|
5
5
|
pyezvizapi/cas.py,sha256=3zHe-_a0KchCmGeAj1of-pV6oMPRUmSCIiDqBFsTK8A,6025
|
|
6
|
-
pyezvizapi/client.py,sha256=
|
|
6
|
+
pyezvizapi/client.py,sha256=fJ5_Dw2ZNAko_GHFQ-Lh8TbLcxF4hlXO6k_w28eBE8I,144373
|
|
7
7
|
pyezvizapi/constants.py,sha256=6-AV7BvQPOQkSXrlrdOhnixDEF3eWiectV5jm5DtRSc,13115
|
|
8
8
|
pyezvizapi/exceptions.py,sha256=8rmxEUQdrziqMe-M1SeeRd0HtP2IDQ2xpJVj7wvOQyo,976
|
|
9
9
|
pyezvizapi/feature.py,sha256=m07s-6aEg0NijwjWZW4EAb23Rrr4RSRaBrYGQlqVwH0,16153
|
|
@@ -13,9 +13,9 @@ pyezvizapi/mqtt.py,sha256=JGjO-uXdKtLidYN1wEZ_bxEKIlNLmnB82Ziiac6oxWs,22373
|
|
|
13
13
|
pyezvizapi/test_cam_rtsp.py,sha256=pbuanoKs_Pryt2f5QctHIngzJG1nD6kv8nulQYh2yPc,5162
|
|
14
14
|
pyezvizapi/test_mqtt.py,sha256=gBaurvo2bu-7sOe14AqNouepJHI-tPWzC3WTpDQbvHM,4155
|
|
15
15
|
pyezvizapi/utils.py,sha256=WHGqI0bIy-G4yX6Vs7i_UDrr7dndx3yzbF_z7rDYGKE,13213
|
|
16
|
-
pyezvizapi-1.0.
|
|
17
|
-
pyezvizapi-1.0.
|
|
18
|
-
pyezvizapi-1.0.
|
|
19
|
-
pyezvizapi-1.0.
|
|
20
|
-
pyezvizapi-1.0.
|
|
21
|
-
pyezvizapi-1.0.
|
|
16
|
+
pyezvizapi-1.0.4.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
17
|
+
pyezvizapi-1.0.4.0.dist-info/licenses/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
18
|
+
pyezvizapi-1.0.4.0.dist-info/METADATA,sha256=RKpymXG5-q6Q09r0K5qyw1QjKgrcl4eYyCOfsjP8nDI,7609
|
|
19
|
+
pyezvizapi-1.0.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
20
|
+
pyezvizapi-1.0.4.0.dist-info/top_level.txt,sha256=gMZTelIi8z7pXyTCQLLaIkxVRrDQ_lS2NEv0WgfHrHs,11
|
|
21
|
+
pyezvizapi-1.0.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|