mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-21 00:13:18 +00:00
fix xx object has no attribute 'smtp_error'
This commit is contained in:
parent
108ad33977
commit
1a84ecffad
@ -1,24 +1,25 @@
|
|||||||
|
import hashlib
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import hashlib
|
|
||||||
import shutil
|
import shutil
|
||||||
import json
|
import smtplib
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
import requests
|
import requests
|
||||||
from datetime import datetime
|
from django.conf import settings
|
||||||
|
from django.utils import timezone
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
|
|
||||||
from django.utils import timezone
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
from account.decorators import super_admin_required
|
from account.decorators import super_admin_required
|
||||||
from problem.models import Problem
|
|
||||||
from account.models import User
|
from account.models import User
|
||||||
from submission.models import Submission
|
|
||||||
from contest.models import Contest
|
from contest.models import Contest
|
||||||
from judge.dispatcher import process_pending_task
|
from judge.dispatcher import process_pending_task
|
||||||
from judge.languages import languages, spj_languages
|
from judge.languages import languages, spj_languages
|
||||||
from options.options import SysOptions
|
from options.options import SysOptions
|
||||||
|
from problem.models import Problem
|
||||||
|
from submission.models import Submission
|
||||||
from utils.api import APIView, CSRFExemptAPIView, validate_serializer
|
from utils.api import APIView, CSRFExemptAPIView, validate_serializer
|
||||||
from utils.shortcuts import send_email, get_env
|
from utils.shortcuts import send_email, get_env
|
||||||
from utils.xss_filter import XSSHtml
|
from utils.xss_filter import XSSHtml
|
||||||
@ -70,15 +71,19 @@ class SMTPTestAPI(APIView):
|
|||||||
to_email=request.data["email"],
|
to_email=request.data["email"],
|
||||||
subject="You have successfully configured SMTP",
|
subject="You have successfully configured SMTP",
|
||||||
content="You have successfully configured SMTP")
|
content="You have successfully configured SMTP")
|
||||||
except Exception as e:
|
except smtplib.SMTPException as e:
|
||||||
# guess error message encoding
|
# guess error message encoding
|
||||||
msg = e.smtp_error
|
msg = b"Failed to send email"
|
||||||
try:
|
try:
|
||||||
|
msg = e.smtp_error
|
||||||
# qq mail
|
# qq mail
|
||||||
msg = msg.decode("gbk")
|
msg = msg.decode("gbk")
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = msg.decode("utf-8", "ignore")
|
msg = msg.decode("utf-8", "ignore")
|
||||||
return self.error(msg)
|
return self.error(msg)
|
||||||
|
except Exception as e:
|
||||||
|
msg = str(e)
|
||||||
|
return self.error(msg)
|
||||||
return self.success()
|
return self.success()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user