forked from ScoDoc/DocScoDoc
sco_photos: exception handling
This commit is contained in:
parent
0657bf0cb2
commit
58dfe8f04b
@ -49,6 +49,7 @@ import os
|
|||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
import PIL
|
import PIL
|
||||||
from PIL import Image as PILImage
|
from PIL import Image as PILImage
|
||||||
@ -372,22 +373,19 @@ def copy_portal_photo_to_fs(etud: dict):
|
|||||||
portal_timeout = sco_preferences.get_preference("portal_timeout")
|
portal_timeout = sco_preferences.get_preference("portal_timeout")
|
||||||
error_message = None
|
error_message = None
|
||||||
try:
|
try:
|
||||||
log(f"copy_portal_photo_to_fs: getting {url}")
|
|
||||||
r = requests.get(url, timeout=portal_timeout)
|
r = requests.get(url, timeout=portal_timeout)
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
log("copy_portal_photo_to_fs: ConnectionError.")
|
|
||||||
error_message = "ConnectionError"
|
error_message = "ConnectionError"
|
||||||
except requests.Timeout:
|
except requests.Timeout:
|
||||||
log("copy_portal_photo_to_fs: Timeout.")
|
|
||||||
error_message = "Timeout"
|
error_message = "Timeout"
|
||||||
except requests.TooManyRedirects:
|
except requests.TooManyRedirects:
|
||||||
log("copy_portal_photo_to_fs: TooManyRedirects.")
|
|
||||||
error_message = "TooManyRedirects"
|
error_message = "TooManyRedirects"
|
||||||
except requests.RequestException:
|
except requests.RequestException:
|
||||||
# log("download failed: exception:\n%s" % traceback.format_exc())
|
error_message = "unknown requests error"
|
||||||
# log("called from:\n" + "".join(traceback.format_stack()))
|
|
||||||
log("copy_portal_photo_to_fs: unknown requests error.")
|
|
||||||
if error_message is not None:
|
if error_message is not None:
|
||||||
|
log("sco_photos: download failed")
|
||||||
|
log(traceback.format_exc())
|
||||||
|
log(f"copy_portal_photo_to_fs: {error_message}")
|
||||||
return (
|
return (
|
||||||
None,
|
None,
|
||||||
f"""{etud["nomprenom"]}: erreur chargement de {url}\n{error_message}""",
|
f"""{etud["nomprenom"]}: erreur chargement de {url}\n{error_message}""",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- mode: python -*-
|
# -*- mode: python -*-
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
SCOVERSION = "9.3.38"
|
SCOVERSION = "9.3.39"
|
||||||
|
|
||||||
SCONAME = "ScoDoc"
|
SCONAME = "ScoDoc"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user