Catch requests exception
This commit is contained in:
parent
bc1cd223b7
commit
97c270b3a5
@ -22,6 +22,7 @@ def get_subject(subject_header):
|
|||||||
|
|
||||||
def send(url, msg, i=0):
|
def send(url, msg, i=0):
|
||||||
full_url = url.replace('{$msg}', msg)
|
full_url = url.replace('{$msg}', msg)
|
||||||
|
try:
|
||||||
r = requests.get(full_url, verify=False)
|
r = requests.get(full_url, verify=False)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
return True
|
return True
|
||||||
@ -44,6 +45,8 @@ def send(url, msg, i=0):
|
|||||||
elif r.status_code == 500:
|
elif r.status_code == 500:
|
||||||
print('Erreur côté serveur.')
|
print('Erreur côté serveur.')
|
||||||
return False
|
return False
|
||||||
|
except requests.exceptions.RequestException:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_emails(imap_server, imap_user, imap_password, inbox, uid):
|
def get_emails(imap_server, imap_user, imap_password, inbox, uid):
|
||||||
|
Loading…
Reference in New Issue
Block a user