Joe 9 ヶ月 前
コミット
5e5183d3d0
2 ファイル変更32 行追加0 行削除
  1. 17 0
      qiaojialiang/FeishuBot.py
  2. 15 0
      qiaojialiang/checkHiveDataUtil.py

+ 17 - 0
qiaojialiang/FeishuBot.py

@@ -0,0 +1,17 @@
+import requests
+
+class FeishuBot:
+    webhook_url = "https://open.feishu.cn/open-apis/bot/v2/hook/your_webhook_id"
+
+    def __init__(self):
+        self.webhook_url = self.webhook_url
+
+    def send_message(self, message_text):
+        headers = {'Content-Type': 'application/json'}
+        data = {
+            "msg_type": "text",
+            "content": {"text": message_text}
+        }
+        response = requests.post(self.webhook_url, json=data, headers=headers)
+        response.raise_for_status()  # 如果响应状态码不是200,则抛出HTTPError异常
+        return response.json()  # 返回JSON响应(如果需要的话)

+ 15 - 0
qiaojialiang/checkHiveDataUtil.py

@@ -2,6 +2,7 @@
 from odps import ODPS
 
 import argparse
+import FeishuBot
 
 ODPS_CONFIG = {
     'ENDPOINT': 'http://service.cn.maxcompute.aliyun.com/api',
@@ -22,6 +23,10 @@ def check_origin_hive(args):
         exit(1)
     else:
         # print('存在 数据 size:', count)
+        # todo 发送阿里云读取到数据通知开始执行下一步骤
+        bot = FeishuBot
+        msg = f'读取project:${project},table:${table},分区:dt= ${partitionDt}/hh=${partitionHh},查询数据总量:${count}'
+        bot.send_message(msg)
         print("0")
 
 
@@ -77,3 +82,13 @@ if __name__ == '__main__':
     # table = 'alg_recsys_sample_all'
     # partition = '20240703'
     check_origin_hive(argv)
+
+# if __name__ == '__main__':
+#     project='1'
+#     table='1'
+#     partitionDt='1'
+#     partitionHh='1'
+#     count='1'
+#     bot = FeishuBot
+#     msg = f'读取project:${project},table:${table},分区:dt= ${partitionDt}/hh=${partitionHh},查询数据总量:${count}'
+#     bot.send_message(msg)