diff options
-rw-r--r-- | pyaggr3g470r/crawler.py | 7 | ||||
-rw-r--r-- | pyaggr3g470r/templates/feed.html | 16 |
2 files changed, 16 insertions, 7 deletions
diff --git a/pyaggr3g470r/crawler.py b/pyaggr3g470r/crawler.py index 56c3552a..22ed5acc 100644 --- a/pyaggr3g470r/crawler.py +++ b/pyaggr3g470r/crawler.py @@ -55,7 +55,8 @@ def get(*args, **kwargs): response = yield from aiohttp.request('GET', *args, **kwargs) return (yield from response.read_and_close(decode=False)) except Exception as e: - print(e) + #print(e) + feed.last_error = str(e) return None @asyncio.coroutine @@ -69,7 +70,11 @@ def parse_feed(user, feed): data = yield from get(feed.link) if data is None: + feed.error_count += 1 return + feed.error_count = 0 + + feed.last_retrieved = datetime.now() a_feed = feedparser.parse(data) if a_feed['bozo'] == 1: diff --git a/pyaggr3g470r/templates/feed.html b/pyaggr3g470r/templates/feed.html index 09bb54cb..12a7aa50 100644 --- a/pyaggr3g470r/templates/feed.html +++ b/pyaggr3g470r/templates/feed.html @@ -11,17 +11,21 @@ <p> {{ _('This feed contains') }} {{ feed.articles.all()|count }} <a href="/articles/{{ feed.id }}/100">{{ _('articles') }}</a> {% if nb_articles != 0 %} - ({{ ((feed.articles.all()|count * 100 ) / nb_articles) | round(2, 'floor') }}% {{ _('of the database') }}) + ({{ ((feed.articles.all()|count * 100 ) / nb_articles) | round(2, 'floor') }}% {{ _('of the database') }}).<br /> {% endif %} - .<br /> + + {% if feed.last_retrieved %} + {{ _("Last download:") }} <pre>{{ feed.last_retrieved }}</pre><br /> + {% endif %} + {% if feed.error_count > 2 %} - <b>{{ _("That feed has encountered too much consecutive errors and won't be retreived anymore.") }}</b> + <b>{{ _("That feed has encountered too much consecutive errors and won't be retrieved anymore.") }}</b><br /> {% elif feed.error_count > 0 %} - {{ _("That feed has encountered some errors but that counter will be reinitialized at the next successful retreiving.") }} + {{ _("The download of this feed has encountered some problems. However its error counter will be reinitialized at the next successful retrieving.") }}<br /> {% endif %} - <br /> + {% if feed.last_error %} - {{ _("Here's the last error encountered while retreiving this feed:") }} <pre>{{ feed.last_error }}</pre> + {{ _("Here's the last error encountered while retreiving this feed:") }} <pre>{{ feed.last_error }}</pre><br /> {% endif %} {{ _('Address of the feed') }}: <a href="{{ feed.link }}">{{ feed.link }}</a><br /> |