GNServer 0.0.0.0.28__py3-none-any.whl → 0.0.0.0.29__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.
- GNServer/_app.py +35 -25
- {gnserver-0.0.0.0.28.dist-info → gnserver-0.0.0.0.29.dist-info}/METADATA +1 -1
- gnserver-0.0.0.0.29.dist-info/RECORD +9 -0
- gnserver-0.0.0.0.28.dist-info/RECORD +0 -9
- {gnserver-0.0.0.0.28.dist-info → gnserver-0.0.0.0.29.dist-info}/WHEEL +0 -0
- {gnserver-0.0.0.0.28.dist-info → gnserver-0.0.0.0.29.dist-info}/licenses/LICENSE +0 -0
- {gnserver-0.0.0.0.28.dist-info → gnserver-0.0.0.0.29.dist-info}/top_level.txt +0 -0
GNServer/_app.py
CHANGED
@@ -45,105 +45,115 @@ console = logging.StreamHandler()
|
|
45
45
|
console.setLevel(logging.INFO)
|
46
46
|
console.setFormatter(logging.Formatter("[GNServer] %(name)s: %(levelname)s: %(message)s"))
|
47
47
|
|
48
|
-
|
48
|
+
PayloadType = Optional[Union[int, str, list, tuple, dict]]
|
49
49
|
|
50
50
|
class _BaseEXception(Exception):
|
51
|
-
def __init__(self, code: str,
|
51
|
+
def __init__(self, code: str, name="", message: Optional[str] = None, payload: PayloadType = None):
|
52
52
|
self._code = code
|
53
|
+
self._name = name
|
53
54
|
self._message = message
|
55
|
+
self._payload = payload
|
54
56
|
|
55
57
|
def assembly(self):
|
56
58
|
"""
|
57
59
|
Собирает ошибку в ответ типа `GNResponse`
|
58
60
|
"""
|
59
|
-
|
61
|
+
payload: dict = {'name': self._name}
|
62
|
+
|
63
|
+
if self._message is not None:
|
64
|
+
payload['message'] = self._message
|
65
|
+
|
66
|
+
if self._payload is not None:
|
67
|
+
payload['payload'] = self._payload
|
68
|
+
|
69
|
+
return gn.GNResponse(f'gn:error:{self._code}', payload=payload)
|
60
70
|
|
61
71
|
|
62
72
|
class GNExceptions:
|
63
73
|
class UnprocessableEntity(_BaseEXception):
|
64
|
-
def __init__(self):
|
74
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
65
75
|
"""
|
66
76
|
# Некорректные данные
|
67
77
|
"""
|
68
|
-
super().__init__('422', "Unprocessable Entity")
|
78
|
+
super().__init__('422', "Unprocessable Entity", message=message, payload=payload)
|
69
79
|
|
70
80
|
class BadRequest(_BaseEXception):
|
71
|
-
def __init__(self):
|
81
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
72
82
|
"""
|
73
83
|
# неправильного синтаксис url или параметров
|
74
84
|
"""
|
75
|
-
super().__init__('400', "Bad Request")
|
85
|
+
super().__init__('400', "Bad Request", message=message, payload=payload)
|
76
86
|
|
77
87
|
class Forbidden(_BaseEXception):
|
78
|
-
def __init__(self):
|
88
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
79
89
|
"""
|
80
90
|
# Доступ запрещён, даже при наличии авторизации
|
81
91
|
"""
|
82
|
-
super().__init__('403', "Forbidden")
|
92
|
+
super().__init__('403', "Forbidden", message=message, payload=payload)
|
83
93
|
|
84
94
|
|
85
95
|
class NotFound(_BaseEXception):
|
86
|
-
def __init__(self):
|
96
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
87
97
|
"""
|
88
98
|
# Ресурс не найден
|
89
99
|
"""
|
90
|
-
super().__init__('404', "Not Found")
|
100
|
+
super().__init__('404', "Not Found", message=message, payload=payload)
|
91
101
|
|
92
102
|
|
93
103
|
class MethodNotAllowed(_BaseEXception):
|
94
|
-
def __init__(self):
|
104
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
95
105
|
"""
|
96
106
|
# Метод запроса не поддерживается данным ресурсом
|
97
107
|
"""
|
98
|
-
super().__init__('405', "Method Not Allowed")
|
108
|
+
super().__init__('405', "Method Not Allowed", message=message, payload=payload)
|
99
109
|
|
100
110
|
|
101
111
|
class Conflict(_BaseEXception):
|
102
|
-
def __init__(self):
|
112
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
103
113
|
"""
|
104
114
|
# Конфликт состояния ресурса (например, дубликат)
|
105
115
|
"""
|
106
|
-
super().__init__('409', "Conflict")
|
116
|
+
super().__init__('409', "Conflict", message=message, payload=payload)
|
107
117
|
|
108
118
|
|
109
119
|
class InternalServerError(_BaseEXception):
|
110
|
-
def __init__(self):
|
120
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
111
121
|
"""
|
112
122
|
# Внутренняя ошибка сервера
|
113
123
|
"""
|
114
|
-
super().__init__('500', "Internal Server Error")
|
124
|
+
super().__init__('500', "Internal Server Error", message=message, payload=payload)
|
115
125
|
|
116
126
|
|
117
127
|
class NotImplemented(_BaseEXception):
|
118
|
-
def __init__(self):
|
128
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
119
129
|
"""
|
120
130
|
# Метод или функционал ещё не реализован
|
121
131
|
"""
|
122
|
-
super().__init__('501', "Not Implemented")
|
132
|
+
super().__init__('501', "Not Implemented", message=message, payload=payload)
|
123
133
|
|
124
134
|
|
125
135
|
class BadGateway(_BaseEXception):
|
126
|
-
def __init__(self):
|
136
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
127
137
|
"""
|
128
138
|
# Ошибка шлюза или прокси при обращении к апстриму
|
129
139
|
"""
|
130
|
-
super().__init__('502', "Bad Gateway")
|
140
|
+
super().__init__('502', "Bad Gateway", message=message, payload=payload)
|
131
141
|
|
132
142
|
|
133
143
|
class ServiceUnavailable(_BaseEXception):
|
134
|
-
def __init__(self):
|
144
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
135
145
|
"""
|
136
146
|
# Сервис временно недоступен
|
137
147
|
"""
|
138
|
-
super().__init__('503', "Service Unavailable")
|
148
|
+
super().__init__('503', "Service Unavailable", message=message, payload=payload)
|
139
149
|
|
140
150
|
|
141
151
|
class GatewayTimeout(_BaseEXception):
|
142
|
-
def __init__(self):
|
152
|
+
def __init__(self, message: Optional[str] = None, payload: PayloadType = None):
|
143
153
|
"""
|
144
154
|
# Таймаут при обращении к апстриму
|
145
155
|
"""
|
146
|
-
super().__init__('504', "Gateway Timeout")
|
156
|
+
super().__init__('504', "Gateway Timeout", message=message, payload=payload)
|
147
157
|
|
148
158
|
def guess_type(filename: str) -> str:
|
149
159
|
"""
|
@@ -0,0 +1,9 @@
|
|
1
|
+
GNServer/___client.py,sha256=hmeUL2Vqp-BnwJeRcLZAaIfRNVxBrRRB_AFk9ofkei4,25459
|
2
|
+
GNServer/__init__.py,sha256=V50sMYrrPdOGuI1iJm-SW7izhX-eggDH16AHvtIKjmM,1480
|
3
|
+
GNServer/_app.py,sha256=FygOu5nl2A7bO5yUA-dAJeczPdfst3clCyOjJ23KSPw,32188
|
4
|
+
GNServer/_client.py,sha256=uF5h5pu0noJ1uNWSdC-kxGvBUwUUmyyAQTt_altNJ_g,29861
|
5
|
+
gnserver-0.0.0.0.29.dist-info/licenses/LICENSE,sha256=WH_t7dKZyWJ5Ld07eYIkUG4Tv6zZWXtAdsUqYAUesn0,1084
|
6
|
+
gnserver-0.0.0.0.29.dist-info/METADATA,sha256=5q7zb4_0MdV4_COCwy-HiIm-SRu84GikJtjM6nauAOE,833
|
7
|
+
gnserver-0.0.0.0.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
+
gnserver-0.0.0.0.29.dist-info/top_level.txt,sha256=-UOUBuD4u7Qkb1o5PdcwyA3kx8xCH2lwy0tJHi26Wb4,9
|
9
|
+
gnserver-0.0.0.0.29.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
GNServer/___client.py,sha256=hmeUL2Vqp-BnwJeRcLZAaIfRNVxBrRRB_AFk9ofkei4,25459
|
2
|
-
GNServer/__init__.py,sha256=V50sMYrrPdOGuI1iJm-SW7izhX-eggDH16AHvtIKjmM,1480
|
3
|
-
GNServer/_app.py,sha256=CZQ1EM-m0FsMTOVyjNIMeDvS0B1MtZMsGV0O1deMyTc,30778
|
4
|
-
GNServer/_client.py,sha256=uF5h5pu0noJ1uNWSdC-kxGvBUwUUmyyAQTt_altNJ_g,29861
|
5
|
-
gnserver-0.0.0.0.28.dist-info/licenses/LICENSE,sha256=WH_t7dKZyWJ5Ld07eYIkUG4Tv6zZWXtAdsUqYAUesn0,1084
|
6
|
-
gnserver-0.0.0.0.28.dist-info/METADATA,sha256=lrvZv_aAc4ggrW0gIWvQerVUexDwivGvyVsNWoDr-cQ,833
|
7
|
-
gnserver-0.0.0.0.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
-
gnserver-0.0.0.0.28.dist-info/top_level.txt,sha256=-UOUBuD4u7Qkb1o5PdcwyA3kx8xCH2lwy0tJHi26Wb4,9
|
9
|
-
gnserver-0.0.0.0.28.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|