diff --git a/sdbs_infra/dashboard/views.py b/sdbs_infra/dashboard/views.py index 619b9a1..fa3e3d4 100644 --- a/sdbs_infra/dashboard/views.py +++ b/sdbs_infra/dashboard/views.py @@ -1,4 +1,5 @@ import asyncio +import logging import socket import time from collections import namedtuple @@ -9,7 +10,6 @@ from urllib.parse import urlparse import aiohttp import feedparser import psutil -from aiohttp import ClientConnectorError from bs4 import BeautifulSoup from django.views.generic import TemplateView from humanize import naturalsize @@ -17,6 +17,8 @@ from humanize import naturalsize from sdbs_infra import settings from sdbs_infra.dashboard.models import Service, Status, Link, Machine, Feed +logger = logging.getLogger(__name__) + class IndexView(TemplateView): template_name = "index.html" @@ -49,8 +51,8 @@ class IndexView(TemplateView): try: async with session.get(link.url) as response: index_status, index_text = response.status, await response.text() - except (asyncio.TimeoutError, ClientConnectorError): - pass + except Exception as exc: + logger.exception(exc) image = link.image.url if link.image else self.extract_favicon(link.url, index_text) @@ -73,8 +75,8 @@ class IndexView(TemplateView): try: async with session.get(service.url) as response: index_status, index_text = response.status, await response.text() - except (asyncio.TimeoutError, ClientConnectorError): - pass + except Exception as exc: + logging.exception(exc) if service.port: a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -121,8 +123,8 @@ class IndexView(TemplateView): 'down': Status.DOWN }.get(check.get('status'), Status.UNKNOWN) last_ping = datetime.fromisoformat(check.get('last_ping')) - except (asyncio.TimeoutError, ClientConnectorError): - pass + except Exception as exc: + logger.exception(exc) result.append({ 'status': status.value, @@ -145,7 +147,8 @@ class IndexView(TemplateView): for entry in entries: entry.published_datetime = datetime(*entry.published_parsed[0:6]) result.extend(parsed_feed.entries) - except (asyncio.TimeoutError, ClientConnectorError): + except Exception as exc: + logger.exception(exc) continue result.sort(key=itemgetter('published_parsed'), reverse=True)