arpakitlib 1.5.37__py3-none-any.whl → 1.5.39__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.
- arpakitlib/{ar_cache_file.py → ar_cache_file_util.py} +1 -1
- arpakitlib/ar_http_request_util.py +8 -3
- arpakitlib/ar_operation_execution_util.py +1 -1
- arpakitlib/ar_postgresql_util.py +1 -1
- arpakitlib/{ar_schedule_uust_api_client.py → ar_schedule_uust_api_client_util.py} +2 -2
- arpakitlib/{ar_yookassa_api_client.py → ar_yookassa_api_client_util.py} +30 -55
- {arpakitlib-1.5.37.dist-info → arpakitlib-1.5.39.dist-info}/METADATA +1 -1
- {arpakitlib-1.5.37.dist-info → arpakitlib-1.5.39.dist-info}/RECORD +17 -17
- /arpakitlib/{ar_base_worker.py → ar_base_worker_util.py} +0 -0
- /arpakitlib/{ar_dream_ai_api_client.py → ar_dream_ai_api_client_util.py} +0 -0
- /arpakitlib/{ar_encrypt_and_decrypt_util.py → ar_encrypt_decrypt_util.py} +0 -0
- /arpakitlib/{ar_file_storage_in_dir.py → ar_file_storage_in_dir_util.py} +0 -0
- /arpakitlib/{ar_json_db.py → ar_json_db_util.py} +0 -0
- /arpakitlib/{ar_run_cmd.py → ar_run_cmd_util.py} +0 -0
- {arpakitlib-1.5.37.dist-info → arpakitlib-1.5.39.dist-info}/LICENSE +0 -0
- {arpakitlib-1.5.37.dist-info → arpakitlib-1.5.39.dist-info}/NOTICE +0 -0
- {arpakitlib-1.5.37.dist-info → arpakitlib-1.5.39.dist-info}/WHEEL +0 -0
@@ -7,7 +7,7 @@ from typing import Optional, Any
|
|
7
7
|
import pytz
|
8
8
|
from pydantic import BaseModel
|
9
9
|
|
10
|
-
from arpakitlib.
|
10
|
+
from arpakitlib.ar_json_db_util import JSONDbFile
|
11
11
|
from arpakitlib.ar_type_util import raise_for_type
|
12
12
|
|
13
13
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
@@ -9,22 +9,27 @@ import requests
|
|
9
9
|
from aiohttp_socks import ProxyConnector
|
10
10
|
|
11
11
|
from arpakitlib.ar_sleep_util import sync_safe_sleep, async_safe_sleep
|
12
|
+
from arpakitlib.ar_type_util import raise_for_type
|
12
13
|
|
13
14
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
14
15
|
|
15
16
|
_logger = logging.getLogger(__name__)
|
16
17
|
|
17
18
|
|
18
|
-
def
|
19
|
+
def sync_make_http_request(
|
19
20
|
*,
|
20
21
|
method: str = "GET",
|
21
22
|
url: str,
|
22
23
|
max_tries_: int = 9,
|
23
24
|
proxy_url_: str | None = None,
|
24
25
|
raise_for_status_: bool = False,
|
25
|
-
timeout_: timedelta = timedelta(seconds=15).total_seconds(),
|
26
|
+
timeout_: timedelta | float = timedelta(seconds=15).total_seconds(),
|
26
27
|
**kwargs
|
27
28
|
) -> requests.Response:
|
29
|
+
if isinstance(timeout_, float):
|
30
|
+
timeout_ = timedelta(seconds=timeout_)
|
31
|
+
raise_for_type(timeout_, timedelta)
|
32
|
+
|
28
33
|
tries_counter = 0
|
29
34
|
|
30
35
|
kwargs["method"] = method
|
@@ -55,7 +60,7 @@ def sync_make_request(
|
|
55
60
|
continue
|
56
61
|
|
57
62
|
|
58
|
-
async def
|
63
|
+
async def async_make_http_request(
|
59
64
|
*,
|
60
65
|
method: str = "GET",
|
61
66
|
url: str,
|
@@ -10,7 +10,7 @@ from typing import Any
|
|
10
10
|
from sqlalchemy import asc
|
11
11
|
from sqlalchemy.orm import Session
|
12
12
|
|
13
|
-
from arpakitlib.
|
13
|
+
from arpakitlib.ar_base_worker_util import BaseWorker
|
14
14
|
from arpakitlib.ar_datetime_util import now_utc_dt
|
15
15
|
from arpakitlib.ar_dict_util import combine_dicts
|
16
16
|
from arpakitlib.ar_sqlalchemy_model_util import OperationDBM, StoryLogDBM
|
arpakitlib/ar_postgresql_util.py
CHANGED
@@ -9,7 +9,7 @@ from typing import Any
|
|
9
9
|
import pytz
|
10
10
|
|
11
11
|
from arpakitlib.ar_dict_util import combine_dicts
|
12
|
-
from arpakitlib.ar_http_request_util import
|
12
|
+
from arpakitlib.ar_http_request_util import async_make_http_request
|
13
13
|
from arpakitlib.ar_type_util import raise_for_type
|
14
14
|
|
15
15
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
@@ -75,7 +75,7 @@ class ScheduleUUSTAPIClient:
|
|
75
75
|
url: str,
|
76
76
|
params: dict | None = None
|
77
77
|
) -> dict[str, Any]:
|
78
|
-
response = await
|
78
|
+
response = await async_make_http_request(
|
79
79
|
url=url,
|
80
80
|
method="GET",
|
81
81
|
params=combine_dicts(params, self.auth_params()),
|
@@ -13,7 +13,7 @@ import requests
|
|
13
13
|
|
14
14
|
from arpakitlib.ar_dict_util import combine_dicts
|
15
15
|
from arpakitlib.ar_enumeration_util import Enumeration
|
16
|
-
from arpakitlib.
|
16
|
+
from arpakitlib.ar_http_request_util import sync_make_http_request, async_make_http_request
|
17
17
|
from arpakitlib.ar_type_util import raise_for_type
|
18
18
|
|
19
19
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
@@ -42,56 +42,23 @@ class YookassaAPIClient:
|
|
42
42
|
self.headers = {"Content-Type": "application/json"}
|
43
43
|
self._logger = logging.getLogger(self.__class__.__name__)
|
44
44
|
|
45
|
-
def _sync_make_request(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
def _sync_make_request(
|
46
|
+
self,
|
47
|
+
*,
|
48
|
+
method: str,
|
49
|
+
url: str,
|
50
|
+
**kwargs
|
51
|
+
) -> requests.Response:
|
52
52
|
if "headers" not in kwargs:
|
53
53
|
kwargs["headers"] = {}
|
54
54
|
kwargs["headers"] = combine_dicts(self.headers, kwargs["headers"])
|
55
55
|
kwargs["auth"] = (self.shop_id, self.secret_key)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
except Exception as err:
|
63
|
-
self._logger.warning(f"{tries}/{max_tries} {err} {method} {url}")
|
64
|
-
if tries >= max_tries:
|
65
|
-
raise YookassaAPIException(err)
|
66
|
-
sync_safe_sleep(timedelta(seconds=0.1).total_seconds())
|
67
|
-
continue
|
68
|
-
|
69
|
-
async def _async_make_request(self, method: str, url: str, **kwargs) -> aiohttp.ClientResponse:
|
70
|
-
max_tries = 7
|
71
|
-
tries = 0
|
72
|
-
|
73
|
-
kwargs["url"] = url
|
74
|
-
kwargs["method"] = method
|
75
|
-
kwargs["timeout"] = aiohttp.ClientTimeout(total=timedelta(seconds=15).total_seconds())
|
76
|
-
if "headers" not in kwargs:
|
77
|
-
kwargs["headers"] = {}
|
78
|
-
kwargs["headers"] = combine_dicts(self.headers, kwargs["headers"])
|
79
|
-
kwargs["auth"] = aiohttp.BasicAuth(login=str(self.shop_id), password=self.secret_key)
|
80
|
-
|
81
|
-
while True:
|
82
|
-
self._logger.info(f"{method} {url}")
|
83
|
-
tries += 1
|
84
|
-
try:
|
85
|
-
async with aiohttp.ClientSession() as session:
|
86
|
-
async with session.request(**kwargs) as response:
|
87
|
-
await response.read()
|
88
|
-
return response
|
89
|
-
except Exception as err:
|
90
|
-
self._logger.warning(f"{tries}/{max_tries} {err} {method} {url}")
|
91
|
-
if tries >= max_tries:
|
92
|
-
raise YookassaAPIException(err)
|
93
|
-
await async_safe_sleep(timedelta(seconds=0.1).total_seconds())
|
94
|
-
continue
|
56
|
+
kwargs["timeout_"] = timedelta(seconds=3)
|
57
|
+
return sync_make_http_request(
|
58
|
+
method=method,
|
59
|
+
url=url,
|
60
|
+
**kwargs
|
61
|
+
)
|
95
62
|
|
96
63
|
def sync_create_payment(
|
97
64
|
self,
|
@@ -121,12 +88,10 @@ class YookassaAPIClient:
|
|
121
88
|
if idempotence_key is None:
|
122
89
|
idempotence_key = str(uuid.uuid4())
|
123
90
|
|
124
|
-
headers = combine_dicts({"Idempotence-Key": idempotence_key})
|
125
|
-
|
126
91
|
response = self._sync_make_request(
|
127
92
|
method="POST",
|
128
93
|
url="https://api.yookassa.ru/v3/payments",
|
129
|
-
headers=
|
94
|
+
headers={"Idempotence-Key": idempotence_key},
|
130
95
|
json=json_body,
|
131
96
|
)
|
132
97
|
|
@@ -154,6 +119,18 @@ class YookassaAPIClient:
|
|
154
119
|
|
155
120
|
return json_data
|
156
121
|
|
122
|
+
async def async_make_request(self, method: str, url: str, **kwargs) -> aiohttp.ClientResponse:
|
123
|
+
if "headers" not in kwargs:
|
124
|
+
kwargs["headers"] = {}
|
125
|
+
kwargs["headers"] = combine_dicts(self.headers, kwargs["headers"])
|
126
|
+
kwargs["auth"] = aiohttp.BasicAuth(login=str(self.shop_id), password=self.secret_key)
|
127
|
+
kwargs["timeout_"] = timedelta(seconds=3)
|
128
|
+
return await async_make_http_request(
|
129
|
+
method=method,
|
130
|
+
url=url,
|
131
|
+
**kwargs
|
132
|
+
)
|
133
|
+
|
157
134
|
async def async_create_payment(
|
158
135
|
self, json_body: dict[str, Any], idempotence_key: Optional[str] = None
|
159
136
|
) -> dict[str, Any]:
|
@@ -180,12 +157,10 @@ class YookassaAPIClient:
|
|
180
157
|
if idempotence_key is None:
|
181
158
|
idempotence_key = str(uuid.uuid4())
|
182
159
|
|
183
|
-
|
184
|
-
|
185
|
-
response = await self._async_make_request(
|
160
|
+
response = await self.async_make_request(
|
186
161
|
method="POST",
|
187
162
|
url="https://api.yookassa.ru/v3/payments",
|
188
|
-
headers=
|
163
|
+
headers={"Idempotence-Key": idempotence_key},
|
189
164
|
json=json_body,
|
190
165
|
)
|
191
166
|
|
@@ -198,7 +173,7 @@ class YookassaAPIClient:
|
|
198
173
|
async def async_get_payment(self, payment_id: str) -> Optional[dict[str, Any]]:
|
199
174
|
raise_for_type(payment_id, str)
|
200
175
|
|
201
|
-
response = await self.
|
176
|
+
response = await self.async_make_request(
|
202
177
|
method="GET",
|
203
178
|
url=f"https://api.yookassa.ru/v3/payments/{payment_id}",
|
204
179
|
)
|
@@ -9,12 +9,12 @@ arpakitlib/ar_arpakit_lib_module_util.py,sha256=YzobxRG8-QJ1L5r_8wBdL668CwXoQRIM
|
|
9
9
|
arpakitlib/ar_arpakit_schedule_uust_api_client.py,sha256=SYWWQDohPnw0qpBIu2hEvGZRVdaI4NUUQdEjnMnseo4,18237
|
10
10
|
arpakitlib/ar_arpakitlib_info.py,sha256=cvgrLnEznmYkCAg1adbY46ATjD6GJd-Yk8PTgOPjpKM,248
|
11
11
|
arpakitlib/ar_base64_util.py,sha256=aZkg2cZTuAaP2IWeG_LXJ6RO7qhyskVwec-Lks0iM-k,676
|
12
|
-
arpakitlib/
|
13
|
-
arpakitlib/
|
12
|
+
arpakitlib/ar_base_worker_util.py,sha256=Y6yRFp1nhhTyv-TeGDao-3q4ICVVJ2zVsKdIlHdiGSI,2897
|
13
|
+
arpakitlib/ar_cache_file_util.py,sha256=Fo2pH-Zqm966KWFBHG_pbiySGZvhIFCYqy7k1weRfJ0,3476
|
14
14
|
arpakitlib/ar_datetime_util.py,sha256=Xe1NiT9oPQzNSG7RVRkhukhbg4i-hhS5ImmV7sPUc8o,971
|
15
15
|
arpakitlib/ar_dict_util.py,sha256=cF5LQJ6tLqyGoEXfDljMDZrikeZoWPw7CgINHIFGvXM,419
|
16
|
-
arpakitlib/
|
17
|
-
arpakitlib/
|
16
|
+
arpakitlib/ar_dream_ai_api_client_util.py,sha256=hDPL9wbG4MjIuhn2ed6qepueogANIkt-NddhhiPUv0Y,4029
|
17
|
+
arpakitlib/ar_encrypt_decrypt_util.py,sha256=GhWnp7HHkbhwFVVCzO1H07m-5gryr4yjWsXjOaNQm1Y,520
|
18
18
|
arpakitlib/ar_enumeration_util.py,sha256=0DN46uyI0Gu9JPDgso3XPbnre7hZZefYTZwmmE1iYH4,2250
|
19
19
|
arpakitlib/ar_fastapi_static/redoc/redoc.standalone.js,sha256=WCuodUNv1qVh0oW5fjnJDwb5AwOue73jKHdI9z8iGKU,909365
|
20
20
|
arpakitlib/ar_fastapi_static/swagger-ui/favicon-16x16.png,sha256=ryStYE3Xs7zaj5dauXMHX0ovcKQIeUShL474tjo-B8I,665
|
@@ -36,12 +36,12 @@ arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css.map,sha256=5wq8eXMLU6Zxb4
|
|
36
36
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js,sha256=ffrLZHHEQ_g84A-ul3yWa10Kk09waOAxHcQXPuZuavg,339292
|
37
37
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map,sha256=9UhIW7MqCOZPAz1Sl1IKfZUuhWU0p-LJqrnjjJD9Xhc,1159454
|
38
38
|
arpakitlib/ar_fastapi_util.py,sha256=7YUx9WL4hc_TAiNjFDqxdcpAutvv0UtI5IEICbBZdVQ,16847
|
39
|
-
arpakitlib/
|
39
|
+
arpakitlib/ar_file_storage_in_dir_util.py,sha256=D3e3rGuHoI6xqAA5mVvEpVVpOWY1jyjNsjj2UhyHRbE,3674
|
40
40
|
arpakitlib/ar_generate_env_example.py,sha256=WseNlk_So6mTVQ2amMuigWYV4ZVmd940POvXtodoYj0,325
|
41
41
|
arpakitlib/ar_hash_util.py,sha256=Iqy6KBAOLBQMFLWv676boI5sV7atT2B-fb7aCdHOmIQ,340
|
42
|
-
arpakitlib/ar_http_request_util.py,sha256=
|
42
|
+
arpakitlib/ar_http_request_util.py,sha256=hMzu2yedUvwIg6gafSakDjXUEC7WH5iplDGiRW9fgPw,3322
|
43
43
|
arpakitlib/ar_ip_util.py,sha256=aEAa1Hvobh9DWX7cmBAPLqnXSTiKe2hRk-WJaiKMaI8,1009
|
44
|
-
arpakitlib/
|
44
|
+
arpakitlib/ar_json_db_util.py,sha256=CEyhIU4WuNmX5mqwBVYxUKSdpFelXvWmf_tJ1fuxMSE,7187
|
45
45
|
arpakitlib/ar_json_util.py,sha256=S8CskZ3uoYuJGCy1GhQ8Ikhn-fxXk-9JpLUbBvXADqI,833
|
46
46
|
arpakitlib/ar_jwt_util.py,sha256=Rhm4ywoTAn6yOV8NLjDASfAtAtheROxxDP40G3XjnuQ,761
|
47
47
|
arpakitlib/ar_list_of_dicts_to_xlsx.py,sha256=MyjEl4Jl4beLVZqLVQMMv0-XDtBD3Xh4Z_ZPDJeFu04,745
|
@@ -50,21 +50,21 @@ arpakitlib/ar_logging_util.py,sha256=c5wX2FLqCzb4aLckLVhIJ7go52rJQ4GN9dIkJ6KMc3o
|
|
50
50
|
arpakitlib/ar_mongodb_util.py,sha256=2ECkTnGAZ92qxioL-fmN6R4yZOSr3bXdXLWTzT1C3vk,4038
|
51
51
|
arpakitlib/ar_need_type_util.py,sha256=n2kBETxzOSVhSVoy7qUtHtuQzgrrxzgi1_iVQimPb9o,1615
|
52
52
|
arpakitlib/ar_openai_util.py,sha256=dHUbfg1sVVCjsNl_fra3iCMEz1bR-Hk9fE-DdYbu7Wc,1215
|
53
|
-
arpakitlib/ar_operation_execution_util.py,sha256=
|
53
|
+
arpakitlib/ar_operation_execution_util.py,sha256=FaMFTIzETdTmGAUHaWaiKSQAleYtjVqFbHq04Gt8htA,9933
|
54
54
|
arpakitlib/ar_parse_command.py,sha256=qpr2OwG3Bf7DFiL9S3iWgtbvtE80RSC35E5zFJvjG1I,2714
|
55
|
-
arpakitlib/ar_postgresql_util.py,sha256=
|
56
|
-
arpakitlib/
|
57
|
-
arpakitlib/
|
55
|
+
arpakitlib/ar_postgresql_util.py,sha256=_2MKkkH0ZSEr6sk6hJw6ml8rlPZIv7b7N_L4tbRg60g,1165
|
56
|
+
arpakitlib/ar_run_cmd_util.py,sha256=D_rPavKMmWkQtwvZFz-Io5Ak8eSODHkcFeLPzNVC68g,1072
|
57
|
+
arpakitlib/ar_schedule_uust_api_client_util.py,sha256=NpCN8GT96aPvE3Lc-IRn653abjI95CmOqNc4pbHIWxo,5780
|
58
58
|
arpakitlib/ar_sleep_util.py,sha256=9ZN4Qo4eZ_q3hjM7vNBQjFRcH-9-sqv3QLSjnxVJE90,1405
|
59
59
|
arpakitlib/ar_sqlalchemy_model_util.py,sha256=tKz6n9zuebo2J9yTr6IQUHoXZ9KF340MAo4UiDXaX_4,4251
|
60
60
|
arpakitlib/ar_sqlalchemy_util.py,sha256=VH23Xld3k5wITkwR0JcaBkO77gmxWn9jlK4eyxKuz_0,3665
|
61
61
|
arpakitlib/ar_ssh_util.py,sha256=jlnss4V4pziBN1rBzoK_lDiWm6nMOqGXfa6NFJSKH-Y,6796
|
62
62
|
arpakitlib/ar_str_util.py,sha256=xSEzmsDvRiZVaxyqFFjcgzpphktCbXg2FHcvsd1DYpA,1885
|
63
63
|
arpakitlib/ar_type_util.py,sha256=I6jbTz7_dxR1lkhz1JfUb5ZyLLdXVhG_-hzjdgT6N6s,1932
|
64
|
-
arpakitlib/
|
64
|
+
arpakitlib/ar_yookassa_api_client_util.py,sha256=5GMvu8paByni8buhc1vpHB7n6oXe0gPfj1LSvnyZCrQ,5307
|
65
65
|
arpakitlib/ar_zabbix_util.py,sha256=MTQbmS0QpNCKNOGONNQHf6j7KTZsKGlIbd5rCH0R0WI,6313
|
66
|
-
arpakitlib-1.5.
|
67
|
-
arpakitlib-1.5.
|
68
|
-
arpakitlib-1.5.
|
69
|
-
arpakitlib-1.5.
|
70
|
-
arpakitlib-1.5.
|
66
|
+
arpakitlib-1.5.39.dist-info/LICENSE,sha256=1jqWIkbnMxDfs_i0SXP5qbV6PHjBr1g8506oW7uPjfg,11347
|
67
|
+
arpakitlib-1.5.39.dist-info/METADATA,sha256=KS0Ppj3Fkn82og5Kf-974S95JebalflOpolXpUx6g4M,2330
|
68
|
+
arpakitlib-1.5.39.dist-info/NOTICE,sha256=wHwmiq3wExfFfgMsE5U5TOBP9_l72ocIG82KurEels0,43
|
69
|
+
arpakitlib-1.5.39.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
70
|
+
arpakitlib-1.5.39.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|