reyserver 1.1.47__py3-none-any.whl → 1.1.48__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.
- reyserver/rbase.py +26 -27
- reyserver/rfile.py +3 -5
- {reyserver-1.1.47.dist-info → reyserver-1.1.48.dist-info}/METADATA +1 -1
- {reyserver-1.1.47.dist-info → reyserver-1.1.48.dist-info}/RECORD +6 -6
- {reyserver-1.1.47.dist-info → reyserver-1.1.48.dist-info}/WHEEL +0 -0
- {reyserver-1.1.47.dist-info → reyserver-1.1.48.dist-info}/licenses/LICENSE +0 -0
reyserver/rbase.py
CHANGED
@@ -9,10 +9,11 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Sequence, Literal
|
12
|
+
from typing import Sequence, Literal, NoReturn
|
13
13
|
from inspect import iscoroutinefunction
|
14
14
|
from contextlib import asynccontextmanager, _AsyncGeneratorContextManager
|
15
|
-
from
|
15
|
+
from http import HTTPStatus
|
16
|
+
from fastapi import FastAPI, HTTPException, UploadFile as File
|
16
17
|
from fastapi.params import (
|
17
18
|
Depends,
|
18
19
|
Path,
|
@@ -26,7 +27,7 @@ from fastapi.params import (
|
|
26
27
|
from reydb.rconn import DatabaseConnectionAsync
|
27
28
|
from reydb.rorm import DatabaseORMModel, DatabaseORMSessionAsync
|
28
29
|
from reykit.rwrap import wrap_cache
|
29
|
-
from reykit.rbase import CoroutineFunctionSimple, Base, Exit, StaticMeta, ConfigMeta
|
30
|
+
from reykit.rbase import CoroutineFunctionSimple, Base, Exit, StaticMeta, ConfigMeta, throw
|
30
31
|
|
31
32
|
from . import rserver
|
32
33
|
|
@@ -35,10 +36,9 @@ __all__ = (
|
|
35
36
|
'ServerBase',
|
36
37
|
'ServerConfig',
|
37
38
|
'ServerExit',
|
38
|
-
'
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'create_depend_sess'
|
39
|
+
'ServerExitAPI',
|
40
|
+
'exit_api',
|
41
|
+
'ServerBind'
|
42
42
|
)
|
43
43
|
|
44
44
|
|
@@ -63,33 +63,32 @@ class ServerExit(ServerBase, Exit):
|
|
63
63
|
"""
|
64
64
|
|
65
65
|
|
66
|
-
class
|
66
|
+
class ServerExitAPI(ServerExit, HTTPException):
|
67
67
|
"""
|
68
|
-
Server
|
68
|
+
Server exit API type.
|
69
69
|
"""
|
70
70
|
|
71
|
-
status_code: int
|
72
71
|
|
73
|
-
|
74
|
-
def __init__(self, text: str | None = None):
|
75
|
-
"""
|
76
|
-
Build instance attributes.
|
77
|
-
|
78
|
-
Parameters
|
79
|
-
----------
|
80
|
-
text : Explain text.
|
81
|
-
"""
|
82
|
-
|
83
|
-
# Super.
|
84
|
-
super().__init__(self.status_code, text)
|
85
|
-
|
86
|
-
|
87
|
-
class ServerExitHTTP404(ServerExitHTTP):
|
72
|
+
def exit_api(code: int = 400, text: str | None = None) -> NoReturn:
|
88
73
|
"""
|
89
|
-
|
74
|
+
Throw exception to exit API.
|
75
|
+
|
76
|
+
Parameters
|
77
|
+
----------
|
78
|
+
code : Response status code.
|
79
|
+
text : Explain text.
|
80
|
+
`None`: Use Default text.
|
90
81
|
"""
|
91
82
|
|
92
|
-
|
83
|
+
# Parameter.
|
84
|
+
if not 400 <= code <= 499:
|
85
|
+
throw(ValueError, code)
|
86
|
+
if text is None:
|
87
|
+
status = HTTPStatus(code)
|
88
|
+
text = status.description
|
89
|
+
|
90
|
+
# Throw exception.
|
91
|
+
raise ServerExitAPI(code, text)
|
93
92
|
|
94
93
|
|
95
94
|
class ServerBind(ServerBase, metaclass=StaticMeta):
|
reyserver/rfile.py
CHANGED
@@ -12,11 +12,9 @@
|
|
12
12
|
from fastapi import APIRouter
|
13
13
|
from fastapi.responses import FileResponse
|
14
14
|
from reydb import rorm
|
15
|
-
from reydb.rorm import DatabaseORMSessionAsync
|
16
|
-
from reydb.rconn import DatabaseConnectionAsync
|
17
15
|
from reykit.ros import FileStore, get_md5
|
18
16
|
|
19
|
-
from .rbase import ServerConfig,
|
17
|
+
from .rbase import ServerConfig, Bind, exit_api
|
20
18
|
|
21
19
|
|
22
20
|
__all__ = (
|
@@ -268,7 +266,7 @@ async def download_file(
|
|
268
266
|
|
269
267
|
# Check.
|
270
268
|
if result.empty:
|
271
|
-
|
269
|
+
exit_api(404)
|
272
270
|
file_name, file_path = result.first()
|
273
271
|
|
274
272
|
# Response.
|
@@ -299,6 +297,6 @@ async def get_file_info(
|
|
299
297
|
|
300
298
|
# Check.
|
301
299
|
if table_info is None:
|
302
|
-
|
300
|
+
exit_api(404)
|
303
301
|
|
304
302
|
return table_info
|
@@ -1,11 +1,11 @@
|
|
1
1
|
reyserver/__init__.py,sha256=7GX64p7uI2eetJH9NJ-DTg-8iyQwOsGcviADFJCPxVA,373
|
2
2
|
reyserver/rall.py,sha256=riyDRTUsigco_Bee1H4aZFb8IgvjnxdX9qcnVb9i9mE,270
|
3
3
|
reyserver/rauth.py,sha256=QyY4gZ0ulpH9Kxvux_jnZBhzfWZZEuOWB1oYU9uzCnY,167
|
4
|
-
reyserver/rbase.py,sha256=
|
4
|
+
reyserver/rbase.py,sha256=IUVkkNsLmQh-QRLX6qtbCjPZAbQAsxoe0goPLCxG9KA,5283
|
5
5
|
reyserver/rclient.py,sha256=pTJtn78jPKgFo5EoQwZRdM0cYHdCs7QUKqfl-jUBRgk,4220
|
6
|
-
reyserver/rfile.py,sha256=
|
6
|
+
reyserver/rfile.py,sha256=6Dwq8_X1kiY1n-9RhbLL3hvdhTAnsAUHyXivcviYcoA,8888
|
7
7
|
reyserver/rserver.py,sha256=hqpemzJHO6xHy_7pO3cvvjnfy8Yfqy8HfyIq4sjk4Dc,5889
|
8
|
-
reyserver-1.1.
|
9
|
-
reyserver-1.1.
|
10
|
-
reyserver-1.1.
|
11
|
-
reyserver-1.1.
|
8
|
+
reyserver-1.1.48.dist-info/METADATA,sha256=T6Q2BrTheAiAziG15T9seCxh_Yi9IRcplL35YTa-wGo,1689
|
9
|
+
reyserver-1.1.48.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
reyserver-1.1.48.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
11
|
+
reyserver-1.1.48.dist-info/RECORD,,
|
File without changes
|
File without changes
|