ezKit 1.12.35__py3-none-any.whl → 1.12.37__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.
- ezKit/database.py +3 -3
- ezKit/fastapix.py +17 -0
- {ezkit-1.12.35.dist-info → ezkit-1.12.37.dist-info}/METADATA +1 -1
- {ezkit-1.12.35.dist-info → ezkit-1.12.37.dist-info}/RECORD +7 -7
- {ezkit-1.12.35.dist-info → ezkit-1.12.37.dist-info}/WHEEL +0 -0
- {ezkit-1.12.35.dist-info → ezkit-1.12.37.dist-info}/licenses/LICENSE +0 -0
- {ezkit-1.12.35.dist-info → ezkit-1.12.37.dist-info}/top_level.txt +0 -0
ezKit/database.py
CHANGED
@@ -683,7 +683,7 @@ class DatabaseAsyncSession:
|
|
683
683
|
return result
|
684
684
|
except Exception as e:
|
685
685
|
await session.rollback()
|
686
|
-
logger.
|
686
|
+
logger.error(e)
|
687
687
|
return None
|
688
688
|
|
689
689
|
# 精确返回一个标量结果 (适用于只返回一行数据的select, 比如 count 查询)
|
@@ -694,7 +694,7 @@ class DatabaseAsyncSession:
|
|
694
694
|
try:
|
695
695
|
return result.scalar_one()
|
696
696
|
except Exception as e:
|
697
|
-
logger.
|
697
|
+
logger.error(e)
|
698
698
|
return None
|
699
699
|
|
700
700
|
# 返回所有结果 (适用于所有select)
|
@@ -706,7 +706,7 @@ class DatabaseAsyncSession:
|
|
706
706
|
rows = result.mappings().all()
|
707
707
|
return [dict(row) for row in rows]
|
708
708
|
except Exception as e:
|
709
|
-
logger.
|
709
|
+
logger.error(e)
|
710
710
|
return []
|
711
711
|
|
712
712
|
|
ezKit/fastapix.py
CHANGED
@@ -7,6 +7,7 @@ from typing import Any
|
|
7
7
|
|
8
8
|
from fastapi import FastAPI, Request
|
9
9
|
from fastapi.exceptions import RequestValidationError
|
10
|
+
from fastapi.middleware.cors import CORSMiddleware
|
10
11
|
from fastapi.responses import JSONResponse
|
11
12
|
from loguru import logger
|
12
13
|
from pydantic import ValidationError
|
@@ -32,6 +33,19 @@ logger.add(
|
|
32
33
|
)
|
33
34
|
|
34
35
|
|
36
|
+
# --------------------------------------------------------------------------------------------------
|
37
|
+
|
38
|
+
|
39
|
+
def CORS(app):
|
40
|
+
app.add_middleware(
|
41
|
+
CORSMiddleware,
|
42
|
+
allow_credentials=True,
|
43
|
+
allow_headers=["*"],
|
44
|
+
allow_methods=["*"],
|
45
|
+
allow_origins=["*"],
|
46
|
+
)
|
47
|
+
|
48
|
+
|
35
49
|
def Response(code: int = 200, data: Any = None, message: str | None = None, status_code: int = 200):
|
36
50
|
return JSONResponse(content={"code": code, "data": data, "message": message}, status_code=status_code)
|
37
51
|
|
@@ -62,6 +76,9 @@ def exceptions(app: FastAPI):
|
|
62
76
|
return Response(code=500, data=None, message="Server Internal Error")
|
63
77
|
|
64
78
|
|
79
|
+
# --------------------------------------------------------------------------------------------------
|
80
|
+
|
81
|
+
|
65
82
|
# 兼容 FastAPI/Uvicorn 的 logging(重要)
|
66
83
|
class InterceptHandler(logging.Handler):
|
67
84
|
"""Intercept Handler"""
|
@@ -3,10 +3,10 @@ ezKit/_file.py,sha256=0qRZhwYuagTgTGrhm-tzAMvEQT4HTJA_xZKqF2bo0ho,1207
|
|
3
3
|
ezKit/bottle.py,sha256=43h4v1kzz6qrLvCt5IMN0H-gFtaT0koG9wETqteXsps,181666
|
4
4
|
ezKit/bottle_extensions.py,sha256=27rogmfK7mL2qUSjXH79IMGZbCVULtYEikql_N9O6Zs,1165
|
5
5
|
ezKit/cipher.py,sha256=7jBarRH7ukSYzkz-Anl8B8JzluhnRz4CLHidPRRj_cg,2939
|
6
|
-
ezKit/database.py,sha256=
|
6
|
+
ezKit/database.py,sha256=WhHh-4L8uhqvDr7oIOPUk0jXLfLv0AVPAAKrOzhhxzQ,30239
|
7
7
|
ezKit/dockerhub.py,sha256=j-wQO-71BsOgExHZhYynuy2k_hCX3on-vg0TH7QCit4,1996
|
8
8
|
ezKit/errors.py,sha256=htTi7vKClHGHf2MX2G88PKr0zzUrFiUHEsrmfqj1Fx8,1425
|
9
|
-
ezKit/fastapix.py,sha256
|
9
|
+
ezKit/fastapix.py,sha256=-nz565ASKvp3nGs9J4wORTHxlhMozqCwv8zREWpmYtI,3382
|
10
10
|
ezKit/http.py,sha256=zhNxJF-x91UqGncXWxVXnhZVpFo_wmmpGnMXVT11y9E,1832
|
11
11
|
ezKit/markdown_to_html.template,sha256=21G2sSVGJn6aJvHd0NN4zY5YiDteKe4UtW36AzBwSdk,22274
|
12
12
|
ezKit/mongo.py,sha256=vsRCjJ2uWbNp-1bnGKICPohNYx25El8XnHp10o-lsM4,2397
|
@@ -17,8 +17,8 @@ ezKit/token.py,sha256=Ac-i9xfq4TqpGyfCzakjrh4NYzxHiN2sCQrMk1tzVi8,1716
|
|
17
17
|
ezKit/utils.py,sha256=U457ahFkxIXuB-qWvS3995xJs-LlkFIX5_ZWVgmL5cY,43130
|
18
18
|
ezKit/xftp.py,sha256=-XQXyhMqeigT63P6sXkSS7r4GROXyqqlkzKxITLWG-g,8278
|
19
19
|
ezKit/zabbix.py,sha256=PkMnfu7mcuotwwIIsHaC9FsNg-gap6hD1xvm0AwSL1Y,33777
|
20
|
-
ezkit-1.12.
|
21
|
-
ezkit-1.12.
|
22
|
-
ezkit-1.12.
|
23
|
-
ezkit-1.12.
|
24
|
-
ezkit-1.12.
|
20
|
+
ezkit-1.12.37.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
21
|
+
ezkit-1.12.37.dist-info/METADATA,sha256=Dc9xJPT4p0iqDczuhL7-qkBtf-4Cuk9RSFMUV3JEQSc,317
|
22
|
+
ezkit-1.12.37.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
ezkit-1.12.37.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
24
|
+
ezkit-1.12.37.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|