internal 0.1.95__py3-none-any.whl → 0.1.97__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.

Potentially problematic release.


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

internal/base_config.py CHANGED
@@ -47,5 +47,10 @@ class BaseConfig(BaseSettings):
47
47
  THIRD_PARTY_BASE_URL: str = "http://third-party-service-api:5000"
48
48
  SCHEDULER_BASE_URL: str = "http://scheduler-service-api:5000"
49
49
 
50
+ # Exception Notify
51
+ SLACK_WEBHOOK_BASE_URL: str = ""
52
+ SLACK_WEBHOOK_CHANNEL: str = ""
53
+ SLACK_WEBHOOK_USERNAME: str = ""
54
+
50
55
  class Config:
51
56
  case_sensitive = False
internal/base_factory.py CHANGED
@@ -16,6 +16,7 @@ from . import database
16
16
  from .const import LOG_FMT, LOG_FMT_NO_DT, LOG_DT_FMT, DEFAULT_LOGGER_NAME
17
17
  from .exception.base_exception import InternalBaseException
18
18
  from .ext.amazon import aws
19
+ from .http.requests import async_request
19
20
  from .http.responses import async_response
20
21
  from .utils import update_dict_with_cast
21
22
 
@@ -111,6 +112,14 @@ class BaseFactory(metaclass=ABCMeta):
111
112
  async def http_exception_handler(request: Request, exc: Exception):
112
113
  app.state.logger.warn(f"Exception, request:{request.__dict__}, exc:{exc}")
113
114
  app.state.logger.warn(traceback.format_exc())
115
+ if self.get_app_config().SLACK_WEBHOOK_BASE_URL and self.get_app_config().SLACK_WEBHOOK_CHANNEL and self.get_app_config().SLACK_WEBHOOK_USERNAME:
116
+ message = f"【{self.DEFAULT_APP_NAME}】Unprocessed Exception, request:{request.__dict__}, exc:{exc}"
117
+ payload = {"channel": f"#{self.get_app_config().SLACK_WEBHOOK_CHANNEL}", "username": self.get_app_config().SLACK_WEBHOOK_USERNAME, "text": message}
118
+ try:
119
+ await async_request(app, "POST", self.get_app_config().SLACK_WEBHOOK_BASE_URL, json=payload)
120
+ except Exception as e:
121
+ app.state.logger.warn(f"Notify failure, Exception:{e}")
122
+
114
123
  return await async_response(code="error_internal_server", message="Internal server error",
115
124
  status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
116
125
 
@@ -0,0 +1,14 @@
1
+ from enum import Enum
2
+
3
+
4
+ class ServiceTicketEventTriggerTypeEnum(str, Enum):
5
+ MANUAL_CANCEL = "manual_cancel"
6
+ BOOKING_REMINDING = "booking_reminding"
7
+ MANUAL_TRACING_START = "manual_tracking_start"
8
+ MANUAL_TRACING_STOP = "manual_tracking_stop"
9
+ MANUAL_CREATE_SMWS = "manual_create_smws"
10
+ MANUAL_IMPORT_RESERVATION_SMWS = "manual_import_reservation_smws"
11
+ IMPORT_RESERVATION_CONFLICT_AUTO_CANCEL = "import_reservation_conflict_auto_cancel"
12
+ LPNR_IN = "lpnr_in"
13
+ LPNR_OUT = "lpnr_out"
14
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 0.1.95
3
+ Version: 0.1.97
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -1,11 +1,11 @@
1
1
  internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- internal/base_config.py,sha256=Mz8QQHzRJAZHs9jJ_vTsHb6OrEMLpA7oXvJ6l0ulG08,1660
3
- internal/base_factory.py,sha256=qCiPpIduOwbBqFFRGJiL29XOXlvl3nyQXRXWZbItEc0,7159
2
+ internal/base_config.py,sha256=uZyIiCsmDw4TvQVyuwKNaOQCFSDtlMkVG6q_tKe8eA0,1794
3
+ internal/base_factory.py,sha256=OJSC9EcpW3s6W049MZWJlquHohAFn0P5i_7kDAv2SLI,7891
4
4
  internal/common_enum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  internal/common_enum/contact_type.py,sha256=uwZjxImXltMmfoAbe-1IeK3ry-p_wJ-wPPWR6NB7WXM,142
6
- internal/common_enum/event_trigger_type.py,sha256=Quer_A_Am7YYsmEIm-fg6ZutQojSnl9r-RNnpdMPo6s,103
7
6
  internal/common_enum/event_type.py,sha256=jMuqiVGhOcYaJ7rYpn-nSpVH08bUsycF7ezHqpXk_Mc,114
8
7
  internal/common_enum/operator_type.py,sha256=dkLgO3EX0jiU-gAj5985FKOs68xBYPX2BNZZ5Vyvk2Y,125
8
+ internal/common_enum/service_ticket_event_trigger_type.py,sha256=g5t4h7-Puk5Gc8AjLi2kSE88iU2WtLvbiv0ZOmidZo0,511
9
9
  internal/const.py,sha256=U1S9r7bjtHgad2oYQoHO19s8D4V0WDUG-L-haV4UaIw,1025
10
10
  internal/database.py,sha256=atf0iyEqeG97eYr3s4GrTHKM5LjLiKlCNWiuAWoE2vs,2124
11
11
  internal/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -24,6 +24,6 @@ internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  internal/model/base_model.py,sha256=svULVdROpcnmTyhIbZ7M6pn40vhb_qIZ5W2CEyuEWZE,3002
25
25
  internal/model/operate.py,sha256=luEoP_Asvso_11qz1SAE1Kn5KxAnDRptM0VylC5tNik,1493
26
26
  internal/utils.py,sha256=0SubS0iUhDvjSX1F4TykasA5-enYJzt2VH-f7_0BnjI,1509
27
- internal-0.1.95.dist-info/METADATA,sha256=TqzwX4Hho6lLb8YFrCjs-6AvsTNkzcTCjnwct6ioMCY,625
28
- internal-0.1.95.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
- internal-0.1.95.dist-info/RECORD,,
27
+ internal-0.1.97.dist-info/METADATA,sha256=AzjKFWS2W-ttXh2ZSeynfihLssJCY9iaECESoVXM66k,625
28
+ internal-0.1.97.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
+ internal-0.1.97.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class EventTriggerEnum(str, Enum):
5
- BOOKING_REMINDING = "booking_reminding"