From f6937b5075ed9be80d93600e0590b7ab477fd6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sun, 4 Sep 2022 14:14:22 +0000 Subject: [PATCH] sync principal --- api/ovdashboard_api/__init__.py | 1 - api/ovdashboard_api/routers/_common.py | 4 +--- api/ovdashboard_api/routers/calendar.py | 4 +--- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/api/ovdashboard_api/__init__.py b/api/ovdashboard_api/__init__.py index edeb9eb..4fa6c6e 100644 --- a/api/ovdashboard_api/__init__.py +++ b/api/ovdashboard_api/__init__.py @@ -48,6 +48,5 @@ _CALDAV_CLIENT = caldav.DAVClient( ) -@run_in_executor def caldav_principal() -> caldav.Principal: return _CALDAV_CLIENT.principal() diff --git a/api/ovdashboard_api/routers/_common.py b/api/ovdashboard_api/routers/_common.py index b6f47f7..58cc388 100644 --- a/api/ovdashboard_api/routers/_common.py +++ b/api/ovdashboard_api/routers/_common.py @@ -37,11 +37,9 @@ class FileNameLister: @dataclass(frozen=True) class CalendarNameLister: async def __call__(self) -> Iterator[str]: - principal = await caldav_principal() - return ( cal.name - for cal in principal.calendars() + for cal in caldav_principal().calendars() ) diff --git a/api/ovdashboard_api/routers/calendar.py b/api/ovdashboard_api/routers/calendar.py index dab9de2..55b1ece 100644 --- a/api/ovdashboard_api/routers/calendar.py +++ b/api/ovdashboard_api/routers/calendar.py @@ -1,7 +1,6 @@ from datetime import datetime, timedelta from typing import Iterator -import caldav from fastapi import APIRouter, Depends, HTTPException, status from .. import caldav_principal @@ -39,8 +38,7 @@ async def get_calendar( elif len(calendar_names) > 1: raise HTTPException(status_code=status.HTTP_409_CONFLICT) - principal: caldav.Principal = await caldav_principal() - calendar = principal.calendar(name=calendar_names[0]) + calendar = caldav_principal().calendar(name=calendar_names[0]) events = []