Ver Fonte

Initial commit

“蒋伟” há 6 meses atrás
pai
commit
b67b1afb01
1 ficheiros alterados com 13 adições e 33 exclusões
  1. 13 33
      DingDing.py

+ 13 - 33
DingDing.py

@@ -65,45 +65,25 @@ def DingTalkSend(info):
     # print(status_defects)
     # status_passed = d.get('launch_status_passed')  # 通过数量
     # print('通过数量:{}'.format(status_passed))
-    status_failed = d.get('launch_status_failed')  # 不通过数量
+    status_failed = d.get('launch_status_broken')  # 不通过数量
     print('不通过数量:{}'.format(status_failed))
-    out_time_url = str(read_yaml_out_time_url())
-    print(out_time_url)
+    # out_time_url = str(read_yaml_out_time_url())
+    # print(out_time_url)
     # 钉钉推送
-    text = (
+    text1 = (
                    f"<font color=\'#FFA500\'>[通知] </font>星辰绘影-{info}"
                    "\n\n服务巡检情况: " + "正常" +
-                   # "\n\n用例运行总数: " + retries_run +
-                   # "\n\n用例未执行数: " + status_defects +
-                   # "\n\n用例通过数量: " + status_passed +
-                   # '''\n\n<font>用例失败数量: </font><font color=\'#FF0000\' size=2>%s</font> \n\n''' +
-                   # "\n\n响应超过2s接口汇总:" + out_time_url +
-                   # "\n\n测试报告地址: \n" + report_url +
                    "\n\n播报时间: " + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
-
-    dd_robot = DingtalkChatbot(read_config_yaml("dingding", "prod_webhook"))
-    ret = dd_robot.send_markdown(title='星辰绘影服务巡检', text=text, is_at_all=False)
-    print(ret)
-
-
-def dingtalk_send_warning(msg):
-    """
-    发送报警超时消息dingtalkchatbot
-    :param msg: 请求返回res
-    :return: none
-    """
-    try:
-        res_time = round(msg.elapsed.total_seconds() * 1000, 2)
-        text = f"<font color=\'#FFA500\'>[通知] </font>青春重庆-报警" \
-               f"\n\n>请求接口路径: {msg.url} " \
-               f"\n\n>请求体: {str(msg.request.body).replace('%', '')} " \
-               f"\n\n>接口响应时间: {res_time}毫秒 " \
-               f"\n\n>播报时间: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} "
-
+    text2 = (
+                   f"<font color=\'#FFA500\'>[通知] </font>星辰绘影-{info}"
+                   '''\n\n<font>服务巡检情况: </font><font color=\'#FF0000\' size=2>异常</font> \n\n''' +
+                   "\n\n播报时间: " + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
+    if status_failed == 0:
+        dd_robot = DingtalkChatbot(read_config_yaml("dingding", "prod_webhook"))
+        ret = dd_robot.send_markdown(title='星辰绘影服务巡检', text=text1, is_at_all=False)
+    else:
         dd_robot = DingtalkChatbot(read_config_yaml("dingding", "prod_webhook"))
-        dd_robot.send_markdown(title='青春重庆', text=text, is_at_all=False)
-    except Exception as e:
-        raise e
+        ret = dd_robot.send_markdown(title='星辰绘影服务巡检', text=text2, is_at_all=False)
 
 
 if __name__ == '__main__':