Browse Source

perf: 账号备份log (#8106)

Co-authored-by: feng626 <1304903146@qq.com>
pull/8111/head
fit2bot 3 years ago committed by GitHub
parent
commit
7647438792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      apps/assets/task_handlers/backup/handlers.py

15
apps/assets/task_handlers/backup/handlers.py

@ -156,10 +156,7 @@ class AccountBackupHandler:
logger.info('步骤完成: 用时 {}s'.format(timedelta))
return files
def send_backup_mail(self, files):
recipients = self.execution.plan_snapshot.get('recipients')
if not recipients:
return
def send_backup_mail(self, files, recipients):
if not files:
return
recipients = User.objects.filter(id__in=list(recipients))
@ -198,8 +195,16 @@ class AccountBackupHandler:
is_success = False
error = '-'
try:
recipients = self.execution.plan_snapshot.get('recipients')
if not recipients:
logger.info(
'\n'
'\033[32m>>> 该备份任务未分配收件人\033[0m'
''
)
else:
files = self.create_excel()
self.send_backup_mail(files)
self.send_backup_mail(files, recipients)
except Exception as e:
self.is_frozen = True
logger.error('任务执行被异常中断')

Loading…
Cancel
Save