internal 1.0.52__tar.gz → 1.0.54__tar.gz

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.

Potentially problematic release.


This version of internal might be problematic. Click here for more details.

Files changed (33) hide show
  1. {internal-1.0.52 → internal-1.0.54}/PKG-INFO +1 -1
  2. {internal-1.0.52 → internal-1.0.54}/pyproject.toml +1 -1
  3. {internal-1.0.52 → internal-1.0.54}/src/internal/base_factory.py +19 -0
  4. {internal-1.0.52 → internal-1.0.54}/src/internal/http/requests.py +9 -0
  5. {internal-1.0.52 → internal-1.0.54}/src/internal/utils.py +1 -1
  6. {internal-1.0.52 → internal-1.0.54}/README.md +0 -0
  7. {internal-1.0.52 → internal-1.0.54}/src/internal/__init__.py +0 -0
  8. {internal-1.0.52 → internal-1.0.54}/src/internal/base_config.py +0 -0
  9. {internal-1.0.52 → internal-1.0.54}/src/internal/common_enum/__init__.py +0 -0
  10. {internal-1.0.52 → internal-1.0.54}/src/internal/common_enum/contact_type.py +0 -0
  11. {internal-1.0.52 → internal-1.0.54}/src/internal/common_enum/description_type.py +0 -0
  12. {internal-1.0.52 → internal-1.0.54}/src/internal/common_enum/event_trigger_type.py +0 -0
  13. {internal-1.0.52 → internal-1.0.54}/src/internal/common_enum/lpnr_direction.py +0 -0
  14. {internal-1.0.52 → internal-1.0.54}/src/internal/common_enum/operator_type.py +0 -0
  15. {internal-1.0.52 → internal-1.0.54}/src/internal/common_enum/order_type.py +0 -0
  16. {internal-1.0.52 → internal-1.0.54}/src/internal/const.py +0 -0
  17. {internal-1.0.52 → internal-1.0.54}/src/internal/database.py +0 -0
  18. {internal-1.0.52 → internal-1.0.54}/src/internal/exception/__init__.py +0 -0
  19. {internal-1.0.52 → internal-1.0.54}/src/internal/exception/base_exception.py +0 -0
  20. {internal-1.0.52 → internal-1.0.54}/src/internal/exception/internal_exception.py +0 -0
  21. {internal-1.0.52 → internal-1.0.54}/src/internal/ext/__init__.py +0 -0
  22. {internal-1.0.52 → internal-1.0.54}/src/internal/ext/amazon/__init__.py +0 -0
  23. {internal-1.0.52 → internal-1.0.54}/src/internal/ext/amazon/aws/__init__.py +0 -0
  24. {internal-1.0.52 → internal-1.0.54}/src/internal/ext/amazon/aws/const.py +0 -0
  25. {internal-1.0.52 → internal-1.0.54}/src/internal/http/__init__.py +0 -0
  26. {internal-1.0.52 → internal-1.0.54}/src/internal/http/responses.py +0 -0
  27. {internal-1.0.52 → internal-1.0.54}/src/internal/interface/__init__.py +0 -0
  28. {internal-1.0.52 → internal-1.0.54}/src/internal/interface/base_interface.py +0 -0
  29. {internal-1.0.52 → internal-1.0.54}/src/internal/middleware/__init__.py +0 -0
  30. {internal-1.0.52 → internal-1.0.54}/src/internal/middleware/log_request.py +0 -0
  31. {internal-1.0.52 → internal-1.0.54}/src/internal/model/__init__.py +0 -0
  32. {internal-1.0.52 → internal-1.0.54}/src/internal/model/base_model.py +0 -0
  33. {internal-1.0.52 → internal-1.0.54}/src/internal/model/operate.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 1.0.52
3
+ Version: 1.0.54
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "internal"
3
- version = "1.0.52"
3
+ version = "1.0.54"
4
4
  description = ""
5
5
  authors = ["Ray <ray@cruisys.com>"]
6
6
  readme = "README.md"
@@ -16,6 +16,7 @@ from fastapi.middleware.cors import CORSMiddleware
16
16
  from . import database
17
17
  from .const import LOG_FMT, LOG_FMT_NO_DT, LOG_DT_FMT, DEFAULT_LOGGER_NAME
18
18
  from .exception.base_exception import InternalBaseException
19
+ from .exception.internal_exception import BadGatewayException, GatewayTimeoutException
19
20
  from .ext.amazon import aws
20
21
  from .http.requests import async_request
21
22
  from .http.responses import async_response
@@ -125,6 +126,24 @@ class BaseFactory(metaclass=ABCMeta):
125
126
  @app.exception_handler(InternalBaseException)
126
127
  async def http_exception_handler(request: Request, exc: InternalBaseException):
127
128
  detail = exc.detail
129
+
130
+ if isinstance(exc, BadGatewayException):
131
+ if self.get_app_config().WEBHOOK_BASE_URL:
132
+ message = f"【{self.DEFAULT_APP_NAME}】Bad gateway, request:{request.__dict__}, exc:{exc}"
133
+ payload = {"text": message}
134
+ try:
135
+ await async_request(app, "POST", self.get_app_config().WEBHOOK_BASE_URL, json=payload)
136
+ except Exception as e:
137
+ app.state.logger.warn(f"Notify failure, Exception:{e}")
138
+ elif isinstance(exc, GatewayTimeoutException):
139
+ if self.get_app_config().WEBHOOK_BASE_URL:
140
+ message = f"【{self.DEFAULT_APP_NAME}】Gateway timeout, request:{request.__dict__}, exc:{exc}"
141
+ payload = {"text": message}
142
+ try:
143
+ await async_request(app, "POST", self.get_app_config().WEBHOOK_BASE_URL, json=payload)
144
+ except Exception as e:
145
+ app.state.logger.warn(f"Notify failure, Exception:{e}")
146
+
128
147
  return await async_response(data=detail.get("data"), code=detail.get("code"), message=detail.get("message"),
129
148
  status_code=exc.status_code)
130
149
 
@@ -36,3 +36,12 @@ async def async_request(app: FastAPI, method, url, current_user: dict = None, **
36
36
  app.state.logger.warn(
37
37
  f"async_request(), Exception, exc: {exc}, url: {url}, method: {method}, kwargs: {kwargs}")
38
38
  raise BadGatewayException(str(exc))
39
+
40
+
41
+ async def send_webhook_message(app: FastAPI, message: str):
42
+ if app.state.config.WEBHOOK_BASE_URL:
43
+ payload = {"text": message}
44
+ try:
45
+ await async_request(app, "POST", app.state.config.WEBHOOK_BASE_URL, json=payload)
46
+ except Exception as e:
47
+ app.state.logger.warn(f"Notify failure, Exception:{e}")
@@ -47,4 +47,4 @@ def update_dict_with_cast(curr_settings: BaseConfig, new_conf: dict):
47
47
 
48
48
 
49
49
  def sanitize_plate_no(plate_no):
50
- return plate_no.replace(STR_DASH, STR_EMPTY)
50
+ return plate_no.replace(STR_DASH, STR_EMPTY).upper()
File without changes