Do not throw on MissingSchema request exception, see #120
This commit is contained in:
parent
540d69f9e2
commit
4df1f1d2a1
@ -113,14 +113,14 @@ class ImageCache(MemoryCache):
|
|||||||
if os.path.isfile(filepath):
|
if os.path.isfile(filepath):
|
||||||
return PIL.Image.open(filepath)
|
return PIL.Image.open(filepath)
|
||||||
# Otherwise, fetch it
|
# Otherwise, fetch it
|
||||||
req = requests.get(url)
|
|
||||||
try:
|
try:
|
||||||
|
req = requests.get(url)
|
||||||
req.raise_for_status()
|
req.raise_for_status()
|
||||||
image = PIL.Image.open(BytesIO(req.content))
|
image = PIL.Image.open(BytesIO(req.content))
|
||||||
if self.storage_dir:
|
if self.storage_dir:
|
||||||
image.save(filepath, format=image.format)
|
image.save(filepath, format=image.format)
|
||||||
return image
|
return image
|
||||||
except (requests.HTTPError, IOError):
|
except (requests.HTTPError, requests.exceptions.MissingSchema, IOError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __init__(self, max_items=200, storage_dir=None):
|
def __init__(self, max_items=200, storage_dir=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user