Skip to content
Snippets Groups Projects
Commit 22b7c2ef authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

CLean up utility code

parent 01b9f7a2
No related branches found
No related tags found
No related merge requests found
import logging
import re
import requests
from django.utils import timezone, formats
from django.core.cache import cache
from ics import Calendar
from requests import RequestException
import logging
import requests
logger = logging.getLogger(__name__)
......@@ -73,14 +73,12 @@ def get_current_events_with_cal(calendar_url: str, limit: int = 5) -> list:
# Return the if so
return current_events
# Else
# Get ICS
try:
calendar: Calendar = Calendar(requests.get(calendar_url, timeout=3).text)
except RequestException as e:
except requests.RequestException as e:
logger.error(str(e))
return cache.get("current_events", [])
return []
# Get events
current_events = get_current_events(calendar, limit)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment