From 84a15e9755b3bcf880b00ef812cb089411ad3c5e Mon Sep 17 00:00:00 2001 From: hhyo Date: Tue, 31 Jul 2018 20:41:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8D=95=E8=8E=B7=E6=B6=88=E6=81=AF=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/notify.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/sql/notify.py b/sql/notify.py index 1808a42505..ffc80015ef 100644 --- a/sql/notify.py +++ b/sql/notify.py @@ -1,5 +1,6 @@ # -*- coding: UTF-8 -*- import datetime +import traceback from threading import Thread from django.contrib.auth.models import Group @@ -125,18 +126,20 @@ def _send(audit_id, msg_type, **kwargs): msg_email_cc = [msg_email_cc] # 判断是发送钉钉还是发送邮件 - if msg_type == 0: - if sys_config.get('mail') == 'true': - msg_sender.send_email(msg_title, msg_content, msg_email_reciver, listCcAddr=msg_email_cc) - if sys_config.get('ding') == 'true': - msg_sender.send_ding(webhook_url, msg_title + '\n' + msg_content) - if msg_type == 1: - if sys_config.get('mail') == 'true': - msg_sender.send_email(msg_title, msg_content, msg_email_reciver, listCcAddr=msg_email_cc) - elif msg_type == 2: - if sys_config.get('ding') == 'true': - msg_sender.send_ding(webhook_url, msg_title + '\n' + msg_content) - + try: + if msg_type == 0: + if sys_config.get('mail') == 'true': + msg_sender.send_email(msg_title, msg_content, msg_email_reciver, listCcAddr=msg_email_cc) + if sys_config.get('ding') == 'true': + msg_sender.send_ding(webhook_url, msg_title + '\n' + msg_content) + if msg_type == 1: + if sys_config.get('mail') == 'true': + msg_sender.send_email(msg_title, msg_content, msg_email_reciver, listCcAddr=msg_email_cc) + elif msg_type == 2: + if sys_config.get('ding') == 'true': + msg_sender.send_ding(webhook_url, msg_title + '\n' + msg_content) + except Exception: + logger.error(traceback.format_exc()) # 异步调用 def send_msg(audit_id, msg_type, **kwargs):