libentry 1.21.2__py3-none-any.whl → 1.21.3__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.
- libentry/api.py +26 -5
- {libentry-1.21.2.dist-info → libentry-1.21.3.dist-info}/METADATA +1 -1
- {libentry-1.21.2.dist-info → libentry-1.21.3.dist-info}/RECORD +8 -8
- {libentry-1.21.2.dist-info → libentry-1.21.3.dist-info}/LICENSE +0 -0
- {libentry-1.21.2.dist-info → libentry-1.21.3.dist-info}/WHEEL +0 -0
- {libentry-1.21.2.dist-info → libentry-1.21.3.dist-info}/entry_points.txt +0 -0
- {libentry-1.21.2.dist-info → libentry-1.21.3.dist-info}/top_level.txt +0 -0
- {libentry-1.21.2.dist-info → libentry-1.21.3.dist-info}/zip-safe +0 -0
libentry/api.py
CHANGED
@@ -10,6 +10,7 @@ __all__ = [
|
|
10
10
|
"APIClient",
|
11
11
|
]
|
12
12
|
|
13
|
+
import asyncio
|
13
14
|
from dataclasses import dataclass, field
|
14
15
|
from time import sleep
|
15
16
|
from typing import Any, AsyncIterable, Callable, Iterable, List, Literal, Mapping, Optional, Tuple, Union
|
@@ -216,6 +217,10 @@ class BaseClient:
|
|
216
217
|
stream: bool,
|
217
218
|
verify: bool,
|
218
219
|
) -> Union[bytes, Iterable[bytes]]:
|
220
|
+
if headers is None:
|
221
|
+
headers = self.headers
|
222
|
+
else:
|
223
|
+
headers = {**self.headers, **headers}
|
219
224
|
response = self.URLLIB3_POOL[int(verify)].request(
|
220
225
|
method=method,
|
221
226
|
url=url,
|
@@ -304,6 +309,10 @@ class BaseClient:
|
|
304
309
|
stream: bool,
|
305
310
|
verify: bool,
|
306
311
|
):
|
312
|
+
if headers is None:
|
313
|
+
headers = self.headers
|
314
|
+
else:
|
315
|
+
headers = {**self.headers, **headers}
|
307
316
|
if not stream:
|
308
317
|
async with httpx.AsyncClient(headers=headers, verify=verify) as client:
|
309
318
|
response = await client.request(
|
@@ -377,7 +386,7 @@ class BaseClient:
|
|
377
386
|
err = e
|
378
387
|
if callable(on_error):
|
379
388
|
on_error(e)
|
380
|
-
sleep(interval)
|
389
|
+
await asyncio.sleep(interval)
|
381
390
|
raise err
|
382
391
|
|
383
392
|
|
@@ -404,8 +413,10 @@ class APIClient(BaseClient):
|
|
404
413
|
verify: Optional[bool] = None,
|
405
414
|
):
|
406
415
|
full_url = urljoin(self.base_url, path)
|
407
|
-
headers
|
408
|
-
|
416
|
+
if headers is None:
|
417
|
+
headers = {}
|
418
|
+
accept = headers["Accept"] if "Accept" in headers else self.headers["Accept"]
|
419
|
+
headers["Accept"] = accept + f"; stream={int(stream)}"
|
409
420
|
body = json.dumps(json_data) if json_data is not None else None
|
410
421
|
content = super().request(
|
411
422
|
method,
|
@@ -481,6 +492,7 @@ class APIClient(BaseClient):
|
|
481
492
|
self,
|
482
493
|
path: Optional[str] = None,
|
483
494
|
*,
|
495
|
+
headers: Optional[Mapping[str, str]] = None,
|
484
496
|
timeout: float = 15,
|
485
497
|
num_trials: int = 5,
|
486
498
|
interval: float = 1,
|
@@ -490,6 +502,7 @@ class APIClient(BaseClient):
|
|
490
502
|
return self.request(
|
491
503
|
"GET",
|
492
504
|
path,
|
505
|
+
headers=headers,
|
493
506
|
timeout=timeout,
|
494
507
|
num_trials=num_trials,
|
495
508
|
interval=interval,
|
@@ -502,6 +515,7 @@ class APIClient(BaseClient):
|
|
502
515
|
path: Optional[str] = None,
|
503
516
|
json_data: Optional[Mapping] = None,
|
504
517
|
*,
|
518
|
+
headers: Optional[Mapping[str, str]] = None,
|
505
519
|
timeout: float = 15,
|
506
520
|
num_trials: int = 5,
|
507
521
|
interval: float = 1,
|
@@ -518,6 +532,7 @@ class APIClient(BaseClient):
|
|
518
532
|
"POST",
|
519
533
|
path,
|
520
534
|
json_data=json_data,
|
535
|
+
headers=headers,
|
521
536
|
timeout=timeout,
|
522
537
|
num_trials=num_trials,
|
523
538
|
interval=interval,
|
@@ -552,8 +567,10 @@ class APIClient(BaseClient):
|
|
552
567
|
verify: Optional[bool] = None,
|
553
568
|
):
|
554
569
|
full_url = urljoin(self.base_url, path)
|
555
|
-
headers
|
556
|
-
|
570
|
+
if headers is None:
|
571
|
+
headers = {}
|
572
|
+
accept = headers["Accept"] if "Accept" in headers else self.headers["Accept"]
|
573
|
+
headers["Accept"] = accept + f"; stream={int(stream)}"
|
557
574
|
body = json.dumps(json_data) if json_data is not None else None
|
558
575
|
content = await super().request_async(
|
559
576
|
method,
|
@@ -629,6 +646,7 @@ class APIClient(BaseClient):
|
|
629
646
|
self,
|
630
647
|
path: Optional[str] = None,
|
631
648
|
*,
|
649
|
+
headers: Optional[Mapping[str, str]] = None,
|
632
650
|
timeout: float = 15,
|
633
651
|
num_trials: int = 5,
|
634
652
|
interval: float = 1,
|
@@ -638,6 +656,7 @@ class APIClient(BaseClient):
|
|
638
656
|
return await self.request_async(
|
639
657
|
"GET",
|
640
658
|
path,
|
659
|
+
headers=headers,
|
641
660
|
timeout=timeout,
|
642
661
|
num_trials=num_trials,
|
643
662
|
interval=interval,
|
@@ -650,6 +669,7 @@ class APIClient(BaseClient):
|
|
650
669
|
path: Optional[str] = None,
|
651
670
|
json_data: Optional[Mapping] = None,
|
652
671
|
*,
|
672
|
+
headers: Optional[Mapping[str, str]] = None,
|
653
673
|
timeout: float = 15,
|
654
674
|
num_trials: int = 5,
|
655
675
|
interval: float = 1,
|
@@ -666,6 +686,7 @@ class APIClient(BaseClient):
|
|
666
686
|
"POST",
|
667
687
|
path,
|
668
688
|
json_data=json_data,
|
689
|
+
headers=headers,
|
669
690
|
timeout=timeout,
|
670
691
|
num_trials=num_trials,
|
671
692
|
interval=interval,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
libentry/__init__.py,sha256=ko2YBIIx5H3dD0tedBkialzJGEDczFaP_PZmT1cIlak,148
|
2
|
-
libentry/api.py,sha256=
|
2
|
+
libentry/api.py,sha256=ei67QL_PEMs1J_utCuh5MifPbAw17BOYnaYtc8d35UY,22923
|
3
3
|
libentry/argparse.py,sha256=NxzXV-jBN51ReZsNs5aeyOfzwYQ5A5nJ95rWoa-FYCs,10415
|
4
4
|
libentry/dataclasses.py,sha256=AQV2PuxplJCwGZ5HKX72U-z-POUhTdy3XtpEK9KNIGQ,4541
|
5
5
|
libentry/executor.py,sha256=cTV0WxJi0nU1TP-cOwmeodN8DD6L1691M2HIQsJtGrU,6582
|
@@ -15,10 +15,10 @@ libentry/service/list.py,sha256=ElHWhTgShGOhaxMUEwVbMXos0NQKjHsODboiQ-3AMwE,1397
|
|
15
15
|
libentry/service/running.py,sha256=FrPJoJX6wYxcHIysoatAxhW3LajCCm0Gx6l7__6sULQ,5105
|
16
16
|
libentry/service/start.py,sha256=mZT7b9rVULvzy9GTZwxWnciCHgv9dbGN2JbxM60OMn4,1270
|
17
17
|
libentry/service/stop.py,sha256=wOpwZgrEJ7QirntfvibGq-XsTC6b3ELhzRW2zezh-0s,1187
|
18
|
-
libentry-1.21.
|
19
|
-
libentry-1.21.
|
20
|
-
libentry-1.21.
|
21
|
-
libentry-1.21.
|
22
|
-
libentry-1.21.
|
23
|
-
libentry-1.21.
|
24
|
-
libentry-1.21.
|
18
|
+
libentry-1.21.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
19
|
+
libentry-1.21.3.dist-info/METADATA,sha256=43wuxNjrLdOaLoW5E55_JEMhGAPAAVTFe5WltenN7L0,813
|
20
|
+
libentry-1.21.3.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
21
|
+
libentry-1.21.3.dist-info/entry_points.txt,sha256=vgHmJZhM-kqM7U9S179UwDD3pM232tpzJ5NntncXi_8,62
|
22
|
+
libentry-1.21.3.dist-info/top_level.txt,sha256=u2uF6-X5fn2Erf9PYXOg_6tntPqTpyT-yzUZrltEd6I,9
|
23
|
+
libentry-1.21.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
24
|
+
libentry-1.21.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|