arpakitlib 1.8.37__py3-none-any.whl → 1.8.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.
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "arpakitlib_project_template_version": "5",
3
- "arpakitlib_project_template_subversion": "6"
3
+ "arpakitlib_project_template_subversion": "7"
4
4
  }
@@ -0,0 +1,43 @@
1
+ import fastapi
2
+ from fastapi import APIRouter
3
+
4
+ from project.api.authorize import require_api_key_dbm_api_authorize_middleware, APIAuthorizeData, \
5
+ require_user_token_dbm_api_authorize_middleware, api_authorize
6
+ from project.api.schema.common import BaseRouteSO
7
+ from project.api.schema.out.common.error import ErrorCommonSO
8
+ from project.api.schema.out.common.raw_data import RawDataCommonSO
9
+ from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
10
+ from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
11
+
12
+
13
+ class CheckSQLAlchemyDbRouteSO(BaseRouteSO, RawDataCommonSO):
14
+ pass
15
+
16
+
17
+ api_router = APIRouter()
18
+
19
+
20
+ @api_router.get(
21
+ path="",
22
+ name="Check sqlalchemy db",
23
+ status_code=fastapi.status.HTTP_200_OK,
24
+ response_model=CheckSQLAlchemyDbRouteSO | ErrorCommonSO
25
+ )
26
+ async def _(
27
+ *,
28
+ request: fastapi.requests.Request,
29
+ response: fastapi.responses.Response,
30
+ api_auth_data: APIAuthorizeData = fastapi.Depends(api_authorize(middlewares=[
31
+ require_api_key_dbm_api_authorize_middleware(
32
+ require_active=True
33
+ ),
34
+ require_user_token_dbm_api_authorize_middleware(
35
+ require_active_user_token=True,
36
+ require_user_roles=[UserDBM.Roles.admin]
37
+ )
38
+ ]))
39
+ ):
40
+ get_cached_sqlalchemy_db().is_conn_good()
41
+ return CheckSQLAlchemyDbRouteSO(
42
+ data={"is_conn_good": get_cached_sqlalchemy_db().is_conn_good()}
43
+ )
@@ -0,0 +1,44 @@
1
+ import fastapi
2
+ from fastapi import APIRouter
3
+
4
+ from arpakitlib.ar_logging_util import init_log_file
5
+ from project.api.authorize import require_api_key_dbm_api_authorize_middleware, APIAuthorizeData, \
6
+ require_user_token_dbm_api_authorize_middleware, api_authorize
7
+ from project.api.schema.common import BaseRouteSO
8
+ from project.api.schema.out.common.error import ErrorCommonSO
9
+ from project.api.schema.out.common.raw_data import RawDataCommonSO
10
+ from project.core.settings import get_cached_settings
11
+ from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
12
+
13
+
14
+ class ClearLogFileRouteSO(BaseRouteSO, RawDataCommonSO):
15
+ pass
16
+
17
+
18
+ api_router = APIRouter()
19
+
20
+
21
+ @api_router.get(
22
+ path="",
23
+ name="Clear log file",
24
+ status_code=fastapi.status.HTTP_200_OK,
25
+ response_model=ClearLogFileRouteSO | ErrorCommonSO
26
+ )
27
+ def _(
28
+ *,
29
+ request: fastapi.requests.Request,
30
+ response: fastapi.responses.Response,
31
+ api_auth_data: APIAuthorizeData = fastapi.Depends(api_authorize(middlewares=[
32
+ require_api_key_dbm_api_authorize_middleware(
33
+ require_active=True
34
+ ),
35
+ require_user_token_dbm_api_authorize_middleware(
36
+ require_active_user_token=True,
37
+ require_user_roles=[UserDBM.Roles.admin]
38
+ )
39
+ ]))
40
+ ):
41
+ init_log_file(log_filepath=get_cached_settings().log_filepath)
42
+ with open(file=get_cached_settings().log_filepath, mode="w") as f:
43
+ f.write("")
44
+ return ClearLogFileRouteSO()
@@ -0,0 +1,33 @@
1
+ import fastapi
2
+ from fastapi import APIRouter
3
+
4
+ from arpakitlib.ar_logging_util import init_log_file
5
+ from project.api.authorize import require_api_key_dbm_api_authorize_middleware, APIAuthorizeData, \
6
+ require_user_token_dbm_api_authorize_middleware, api_authorize
7
+ from project.core.settings import get_cached_settings
8
+ from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
9
+
10
+ api_router = APIRouter()
11
+
12
+
13
+ @api_router.get(
14
+ path="",
15
+ name="Get log file",
16
+ status_code=fastapi.status.HTTP_200_OK,
17
+ )
18
+ async def _(
19
+ *,
20
+ request: fastapi.requests.Request,
21
+ response: fastapi.responses.Response,
22
+ api_auth_data: APIAuthorizeData = fastapi.Depends(api_authorize(middlewares=[
23
+ require_api_key_dbm_api_authorize_middleware(
24
+ require_active=True
25
+ ),
26
+ require_user_token_dbm_api_authorize_middleware(
27
+ require_active_user_token=True,
28
+ require_user_roles=[UserDBM.Roles.admin]
29
+ )
30
+ ]))
31
+ ):
32
+ init_log_file(log_filepath=get_cached_settings().log_filepath)
33
+ return fastapi.responses.FileResponse(path=get_cached_settings().log_filepath)
@@ -2,7 +2,8 @@ from fastapi import APIRouter
2
2
 
3
3
  from project.api.router.admin import get_auth_data, get_arpakitlib_project_template_info, raise_fake_error, \
4
4
  reinit_sqlalchemy_db, get_story_log, init_sqlalchemy_db, get_sqlalchemy_db_table_name_to_amount, \
5
- get_operation_allowed_statuses, get_operation, create_operation, get_operation_allowed_types
5
+ get_operation_allowed_statuses, get_operation, create_operation, get_operation_allowed_types, get_log_file, \
6
+ clear_log_file, check_sqlalchemy_db
6
7
 
7
8
  main_admin_api_router = APIRouter()
8
9
 
@@ -60,3 +61,18 @@ main_admin_api_router.include_router(
60
61
  router=create_operation.api_router,
61
62
  prefix="/create_operation"
62
63
  )
64
+
65
+ main_admin_api_router.include_router(
66
+ router=get_log_file.api_router,
67
+ prefix="/get_log_file"
68
+ )
69
+
70
+ main_admin_api_router.include_router(
71
+ router=clear_log_file.api_router,
72
+ prefix="/clear_log_file"
73
+ )
74
+
75
+ main_admin_api_router.include_router(
76
+ router=check_sqlalchemy_db.api_router,
77
+ prefix="/check_sqlalchemy_db"
78
+ )
@@ -45,7 +45,18 @@ class OperationExecutorWorker(BaseWorker):
45
45
  elif operation_dbm.type == OperationDBM.Types.raise_fake_error_:
46
46
  self._logger.error(f"{OperationDBM.Types.raise_fake_error_}")
47
47
  raise Exception(f"{OperationDBM.Types.raise_fake_error_}")
48
- # ...
48
+ else:
49
+ with self.sqlalchemy_db.new_session() as session:
50
+ operation_dbm: OperationDBM = session.query(
51
+ OperationDBM
52
+ ).filter(OperationDBM.id == operation_dbm.id).one()
53
+ operation_dbm.output_data = combine_dicts(
54
+ operation_dbm.output_data,
55
+ {"warning": f"unknown operation_type = {operation_dbm.type=}"}
56
+ )
57
+ session.commit()
58
+ session.refresh(operation_dbm)
59
+ self._logger.info(f"unknown operation_type, {operation_dbm.id=}, {operation_dbm.type=}")
49
60
 
50
61
  async def async_execute_operation(self, *, operation_dbm: OperationDBM):
51
62
  if operation_dbm.type == OperationDBM.Types.healthcheck_:
@@ -53,7 +64,19 @@ class OperationExecutorWorker(BaseWorker):
53
64
  elif operation_dbm.type == OperationDBM.Types.raise_fake_error_:
54
65
  self._logger.error(f"{OperationDBM.Types.raise_fake_error_}")
55
66
  raise Exception(f"{OperationDBM.Types.raise_fake_error_}")
56
- # ...
67
+ else:
68
+ async with self.sqlalchemy_db.new_async_session() as session:
69
+ result = await session.execute(
70
+ sqlalchemy.select(OperationDBM).filter(OperationDBM.id == operation_dbm.id)
71
+ )
72
+ operation_dbm: OperationDBM = result.scalar_one()
73
+ operation_dbm.output_data = combine_dicts(
74
+ operation_dbm.output_data,
75
+ {"warning": f"unknown operation_type = {operation_dbm.type}"}
76
+ )
77
+ await session.commit()
78
+ await session.refresh(operation_dbm)
79
+ self._logger.info(f"unknown operation_type, {operation_dbm.id=}, {operation_dbm.type=}")
57
80
 
58
81
  def sync_run(self):
59
82
  # 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: arpakitlib
3
- Version: 1.8.37
3
+ Version: 1.8.39
4
4
  Summary: arpakitlib
5
5
  License: Apache-2.0
6
6
  Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
@@ -8,7 +8,7 @@ arpakitlib/_arpakit_project_template_v_5/alembic/env.py,sha256=Qesmnj5A2kB-Doeuf
8
8
  arpakitlib/_arpakit_project_template_v_5/alembic/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
9
9
  arpakitlib/_arpakit_project_template_v_5/alembic/versions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  arpakitlib/_arpakit_project_template_v_5/alembic.ini,sha256=8fuyeEvGBiPGbxEFy8ISBV3xX_fgVmuhEGpB10_B5Uo,3733
11
- arpakitlib/_arpakit_project_template_v_5/arpakitlib_project_template_info.json,sha256=1yBXVYHqWXXFkBgsR8s0cnmOUp-UPhfz4_AboylAxGI,97
11
+ arpakitlib/_arpakit_project_template_v_5/arpakitlib_project_template_info.json,sha256=tHWnMtxRMs4bWD1lB84oODv26e4-p2zTK1wpLWHvG9g,97
12
12
  arpakitlib/_arpakit_project_template_v_5/command/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  arpakitlib/_arpakit_project_template_v_5/command/alembic_history.sh,sha256=OMnDNtHIksGh9iavWnzbtxcudZW4vjdcISsBXvzZSPw,22
14
14
  arpakitlib/_arpakit_project_template_v_5/command/alembic_revision_autogenerate.sh,sha256=yW2i-SBOtBx15Ya0poVQqKkJM5t2JZp06r9AEW-DmGE,46
@@ -94,16 +94,19 @@ arpakitlib/_arpakit_project_template_v_5/project/api/openapi_ui.py,sha256=PLhH-W
94
94
  arpakitlib/_arpakit_project_template_v_5/project/api/response.py,sha256=xZMymP2BuQaRNVWLeIp3UgUUo-MFN8MJnsn9Al4vOb8,1028
95
95
  arpakitlib/_arpakit_project_template_v_5/project/api/router/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
96
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
+ arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/check_sqlalchemy_db.py,sha256=maO6fGrTgho9n3097bVldamIIA4IGNx0I7xN7xgJES8,1461
98
+ arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/clear_log_file.py,sha256=A9lTekkibvCs2Czlpr-iE8Q7IzUJQfF-BhYm5D2Y4hA,1502
97
99
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/create_operation.py,sha256=rnypweyZVi7d0ifWHSeQvUtpMPRelSYOv_pTtltvLp4,2597
98
100
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_arpakitlib_project_template_info.py,sha256=RDbxtAnUsdpiPWslVZNBkhk6klxbxhnO8S58mOAI3m8,1513
99
101
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_auth_data.py,sha256=gney8IDXu7Qm1Sd09at7TNfo1JC2-ap0MlDomvdYGJI,1385
102
+ arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_log_file.py,sha256=rzEPco45I-4FzrlbI3z5B-smhrHFIVIsDiHtTULoE4g,1162
100
103
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation.py,sha256=bF2IstPPA2I1v29aoPBHsxlQhWI9bzAWBjGfg8lDUpg,2416
101
104
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_statuses.py,sha256=gRvpuBo60rDpzBhRtS2ElRjHS9KZqKgJQaiSjoY8BZY,1328
102
105
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_types.py,sha256=wACUgyQy4pkVUUKakBUyzxQxW4_3OqA3GShPj5MRWEM,1307
103
106
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_sqlalchemy_db_table_name_to_amount.py,sha256=6XFnF-Yv2QajvY7OfPphjDDlOVb5xVz8afY6f_-NqWc,1391
104
107
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_story_log.py,sha256=7y2OFyEePVooC6REPII64s_WbEWs3GSltpQLGaBKgQA,2406
105
108
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/init_sqlalchemy_db.py,sha256=PRsYoEfej5qAFspBqqQCDRZXOIwF358QIzh1HuYIDl4,1493
106
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/main_router.py,sha256=AOoL7U4709e7x6_3CFeSUVNZRc8MCol7RtFyNmNds6s,1738
109
+ arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/main_router.py,sha256=7je8zr-0j_myHqBsN9DeB5yP6MzFiIUntEhvlu26Z6M,2125
107
110
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/raise_fake_error.py,sha256=kMr06QR39XVUoVwUuwJHoQmaWHvlfi2j53ZCMX3CU48,1048
108
111
  arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/reinit_sqlalchemy_db.py,sha256=oZNxVfGP83uM5WKh0-3uJRCYRuxlSJ7lAtRGOBTg0lM,1509
109
112
  arpakitlib/_arpakit_project_template_v_5/project/api/router/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -164,7 +167,7 @@ arpakitlib/_arpakit_project_template_v_5/project/json_db/json_db.py,sha256=tBML-
164
167
  arpakitlib/_arpakit_project_template_v_5/project/more/helloworld,sha256=eH7Hbcr9IMGQjrCTahL5Ht0QWrXNfswrGuIDJkg0Xf8,11
165
168
  arpakitlib/_arpakit_project_template_v_5/project/operation_execution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
169
  arpakitlib/_arpakit_project_template_v_5/project/operation_execution/const.py,sha256=dcvj5C9E2F2KCsGZPBBncQf_EvVJAC1qQgnyD8P4ZEw,6
167
- arpakitlib/_arpakit_project_template_v_5/project/operation_execution/operation_executor_worker.py,sha256=-OaNyiZoeTRsLWLjctqAd0IARaWjsvNLKj1DW9gAdoc,10816
170
+ arpakitlib/_arpakit_project_template_v_5/project/operation_execution/operation_executor_worker.py,sha256=pAcvuAVgWc86Vyx3-I21rPvBr9ZxUNaLRoS7VEwkETw,12129
168
171
  arpakitlib/_arpakit_project_template_v_5/project/operation_execution/scheduled_operation_creator_worker.py,sha256=yna75650lZUy7GlV2TYq2_2DOp6zL1hO45g4IMcYE70,4211
169
172
  arpakitlib/_arpakit_project_template_v_5/project/operation_execution/scheduled_operations.py,sha256=BNqlXqHjf7-Bno-HtpCdJho0CFZdi6NUmGOTgIuPDkc,1721
170
173
  arpakitlib/_arpakit_project_template_v_5/project/operation_execution/util.py,sha256=nau1QnUh37CL6rfniwQ7rfQkh5Rf8qE01ruFdNv4H8k,785
@@ -365,8 +368,8 @@ arpakitlib/ar_type_util.py,sha256=Cs_tef-Fc5xeyAF54KgISCsP11NHyzIsglm4S3Xx7iM,40
365
368
  arpakitlib/ar_wata_api_client.py,sha256=gdHOqDbuqxhTjVDtRW1DvkRJLdDofCrOq51GTctzLns,242
366
369
  arpakitlib/ar_yookassa_api_client_util.py,sha256=VozuZeCJjmLd1zj2BdC9WfiAQ3XYOrIMsdpNK-AUlm0,5347
367
370
  arpakitlib/ar_zabbix_api_client_util.py,sha256=AV7yxzG46blyQQDI-is0BwHfzuZlrkiHOkuOpfzQ90A,7934
368
- arpakitlib-1.8.37.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
369
- arpakitlib-1.8.37.dist-info/METADATA,sha256=AqGXX852Y995aIgwXvEJZILPclq4QEhfPlKYer0Kpxs,3477
370
- arpakitlib-1.8.37.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
371
- arpakitlib-1.8.37.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
372
- arpakitlib-1.8.37.dist-info/RECORD,,
371
+ arpakitlib-1.8.39.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
372
+ arpakitlib-1.8.39.dist-info/METADATA,sha256=xHNeRJ9pc9QohSxVp16CwDlxCiayVi7BHEKXBSUUARM,3477
373
+ arpakitlib-1.8.39.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
374
+ arpakitlib-1.8.39.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
375
+ arpakitlib-1.8.39.dist-info/RECORD,,