ovdashboard/api/ovdashboard_api/__init__.py

22 lines
492 B
Python
Raw Normal View History

2022-09-02 15:28:52 +00:00
import functools
from typing import Any
from webdav3.client import Client, Resource
2022-08-29 11:27:18 +00:00
from .config import SETTINGS
2022-09-02 15:28:52 +00:00
_WEBDAV_CLIENT = Client({
2022-08-29 11:27:18 +00:00
"webdav_hostname": SETTINGS.webdav_url,
"webdav_login": SETTINGS.dav_username,
"webdav_password": SETTINGS.dav_password,
})
2022-09-02 15:28:52 +00:00
@functools.lru_cache
def webdav_resource(remote_path: Any) -> Resource:
return _WEBDAV_CLIENT.resource(remote_path)
def webdav_list(remote_path: str) -> list:
return _WEBDAV_CLIENT.list(remote_path)