Browse Source

report_push: 邮件发送增加失败重试

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 4 years ago
parent
commit
d12d17b4bb
1 changed files with 6 additions and 4 deletions
  1. 6 4
      report_push.py

+ 6 - 4
report_push.py

@@ -445,7 +445,7 @@ class ReportPush(object):
     """
 
     sql_6 = """insert into report_push_log(name, mail, report_name, push_time, send_status, status) values(%s, %s, 
-    %s, now(), %s, 1) """
+    %s, now(), %s, 1, %s) """
 
     # 根据项目id获取集团id和名称
     sql_7 = """
@@ -481,11 +481,13 @@ class ReportPush(object):
                         # for mail in self.mails:
                         result = email_util.send_mail_by_admin(title, content, value[1], value[2], value[3])
                         if result:
-                            log_data = [value[0], value[1], value[2], 1]
+                            log_data = [value[0], value[1], value[2], 1, 'success!!!']
                         else:
-                            log_data = [value[0], value[1], value[2], -1]
+                            result = email_util.send_mail_by_admin(title, content, value[1], value[2], value[3])
+                            if not result:
+                                log_data = [value[0], value[1], value[2], -1, '第二次发送失败']
                 except Exception as e:
-                    log_data = [value[0], value[1], value[2], -1]
+                    log_data = [value[0], value[1], value[2], -1, str(e)]
                     print(str(e))
                 logs.append(log_data)
             message[3] = '邮件发送成功'