diff --git a/domain_admin/service/cache_domain_info_service.py b/domain_admin/service/cache_domain_info_service.py index 2396ee592d..13a53ec658 100644 --- a/domain_admin/service/cache_domain_info_service.py +++ b/domain_admin/service/cache_domain_info_service.py @@ -7,7 +7,6 @@ from domain_admin.model.cache_domain_info_model import CacheDomainInfoModel from domain_admin.utils import domain_util -from domain_admin.utils import domain_util from domain_admin.utils.whois_util import whois_util @@ -34,7 +33,7 @@ def get_domain_info(domain: str) -> CacheDomainInfoModel: domain=root_domain, domain_start_time=domain_whois['start_time'], domain_expire_time=domain_whois['expire_time'], - expire_time=datetime.now() + timedelta(hours=1) + expire_time=domain_whois['expire_time'] - timedelta(minutes=3) ) return row diff --git a/domain_admin/service/domain_service.py b/domain_admin/service/domain_service.py index 67afcb2042..aae0f7718d 100644 --- a/domain_admin/service/domain_service.py +++ b/domain_admin/service/domain_service.py @@ -1,15 +1,13 @@ # -*- coding: utf-8 -*- -import json -import os import time import traceback import warnings from datetime import datetime -from playhouse.shortcuts import model_to_dict from peewee import chunked +from playhouse.shortcuts import model_to_dict + from domain_admin.log import logger -from domain_admin.model.base_model import db from domain_admin.model.domain_model import DomainModel from domain_admin.model.group_model import GroupModel from domain_admin.model.log_scheduler_model import LogSchedulerModel @@ -22,7 +20,6 @@ from domain_admin.utils import domain_util from domain_admin.utils.cert_util import cert_common from domain_admin.utils.flask_ext.app_exception import AppException, ForbiddenAppException -from concurrent.futures import ThreadPoolExecutor def add_domain(data): diff --git a/domain_admin/service/email_service.py b/domain_admin/service/email_service.py index 0715cb1307..5fe1e31b0b 100644 --- a/domain_admin/service/email_service.py +++ b/domain_admin/service/email_service.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- -from domain_admin.log import logger from domain_admin.service import system_service from domain_admin.utils.email_util import EmailServer -from domain_admin.utils.flask_ext.app_exception import AppException -def send_email(content: str, - to_addresses: list, - content_type: str = 'plain'): +def send_email( + content: str, + to_addresses: list, + content_type: str = 'plain' +): """ 发送邮件 :param content: diff --git a/domain_admin/utils/email_util.py b/domain_admin/utils/email_util.py index 0b8219c867..cbec564059 100644 --- a/domain_admin/utils/email_util.py +++ b/domain_admin/utils/email_util.py @@ -6,7 +6,16 @@ class EmailServer(object): - def __init__(self, mail_host, mail_port,mail_alias, mail_username, mail_password): + """ + 邮件发送 + """ + + def __init__(self, + mail_host, + mail_port, + mail_alias, + mail_username, + mail_password): self.mail_host = mail_host self.mail_port = mail_port self.mail_alias = mail_alias @@ -24,6 +33,11 @@ def server(self): return self._server + def quit(self): + if self.server: + self.server.quit() + self._server = None + def get_server(self): """ 获取邮件服务器 @@ -47,15 +61,11 @@ def get_server(self): return server - def quit(self): - if self.server: - self.server.quit() - def get_email_content(self, subject, content, content_type='plain'): # 构造邮件 msg = MIMEText(content, content_type, 'utf-8') # 邮箱昵称、发件人邮箱账号 - msg['From'] = formataddr([self.mail_alias, self.mail_username]) + msg['From'] = formataddr((self.mail_alias, self.mail_username)) # msg['To'] = to_addresses.join(',') msg['Subject'] = subject return msg