mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-11-01 09:09:51 +00:00
Adding error handling for new icon feed link fetcher.
This commit is contained in:
parent
f2dfacca8a
commit
5b99ab01ec
1 changed files with 13 additions and 2 deletions
|
|
@ -11,11 +11,17 @@ import gzip
|
|||
import datetime
|
||||
import requests
|
||||
from PIL import BmpImagePlugin, PngImagePlugin, Image
|
||||
from socket import error as SocketError
|
||||
from boto.s3.key import Key
|
||||
from StringIO import StringIO
|
||||
from django.conf import settings
|
||||
from apps.rss_feeds.models import MFeedPage, MFeedIcon
|
||||
from utils import log as logging
|
||||
from utils.feed_functions import timelimit, TimeoutError
|
||||
from OpenSSL.SSL import Error as OpenSSLError
|
||||
from pyasn1.error import PyAsn1Error
|
||||
from requests.packages.urllib3.exceptions import LocationParseError
|
||||
|
||||
|
||||
class IconImporter(object):
|
||||
|
||||
|
|
@ -188,8 +194,13 @@ class IconImporter(object):
|
|||
content = MFeedPage.get_data(feed_id=self.feed.pk)
|
||||
url = self._url_from_html(content)
|
||||
if not url:
|
||||
content = requests.get(self.feed.feed_link).content
|
||||
url = self._url_from_html(content)
|
||||
try:
|
||||
content = requests.get(self.feed.feed_link).content
|
||||
url = self._url_from_html(content)
|
||||
except (AttributeError, SocketError, requests.ConnectionError,
|
||||
requests.models.MissingSchema, requests.sessions.InvalidSchema,
|
||||
LocationParseError, OpenSSLError, PyAsn1Error), e:
|
||||
logging.debug(" ---> ~SN~FRFailed~FY to fetch ~FGfeed icon~FY: %s" % e)
|
||||
if url:
|
||||
image, image_file = self.get_image_from_url(url)
|
||||
return image, image_file, url
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue