From 6859e29986f0b3e4e846f107f27102aeda5e6bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Wed, 31 Aug 2022 02:22:57 +0000 Subject: [PATCH] improved typing --- api/ovkiosk/dav_file.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/api/ovkiosk/dav_file.py b/api/ovkiosk/dav_file.py index 0d909ff..1d690d4 100644 --- a/api/ovkiosk/dav_file.py +++ b/api/ovkiosk/dav_file.py @@ -1,7 +1,7 @@ import logging from io import BytesIO from threading import Lock -from typing import Any +from typing import Any, Optional from apscheduler.schedulers.asyncio import AsyncIOScheduler from webdav3.client import Client, Resource @@ -10,9 +10,8 @@ _logger = logging.getLogger(__name__) class DavFile: - __instances = None + __instances: Optional[list["DavFile"]] = None __scheduler = None - __job = None def __init__(self, client: Client, path: Any) -> None: self.__resource: Resource = client.resource(path) @@ -25,7 +24,7 @@ class DavFile: DavFile.__instances.append(self) - def update(self) -> None: + def download(self) -> None: _logger.info(f"updating {self.__resource}") with self.__lock: self.__buffer.seek(0) @@ -33,8 +32,8 @@ class DavFile: self.__resource.write_to(self.__buffer) @classmethod - def refresh(cls, refresh_interval: int = 60): - if cls.__job is not None: + def refresh(cls, refresh_interval: int = 60) -> None: + if cls.__scheduler is not None: cls.__scheduler.reschedule_job( job_id=cls.__name__, trigger="interval", @@ -44,13 +43,13 @@ class DavFile: def tick() -> None: for davfile in DavFile.__instances: - davfile.update() + davfile.download() cls.__scheduler = AsyncIOScheduler() cls.__scheduler.start() cls.__scheduler.add_job(tick) - cls.__job = cls.__scheduler.add_job( + cls.__scheduler.add_job( tick, id=cls.__name__, trigger="interval",