Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions caldav/async_davclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -1271,20 +1271,16 @@ async def get_calendars(
## Reading the config file and RFC 6764 discovery are blocking, so the
## clients are resolved in a thread, ref
## https://github.com/python-caldav/caldav/issues/794
try:
targets = await asyncio.to_thread(
_get_calendars_targets,
AsyncDAVClient,
calendar_url=calendar_url,
calendar_name=calendar_name,
raise_errors=raise_errors,
**kwargs,
)
except Exception as e:
if raise_errors:
raise
log.error(f"Failed to create async client: {e}")
return CalendarCollection()
## Errors here are mistakes in the configuration, raised as in sync mode:
## raise_errors=False only skips servers that fail below
targets = await asyncio.to_thread(
_get_calendars_targets,
AsyncDAVClient,
calendar_url=calendar_url,
calendar_name=calendar_name,
raise_errors=raise_errors,
**kwargs,
)

clients = [t[0] for t in targets]
calendars: list = []
Expand Down
19 changes: 5 additions & 14 deletions caldav/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,20 +1213,11 @@ def _get_calendars_targets(
raise ValueError("Could not create DAV client - no configuration found")
return []

# Resolve config_file path from env if not given (mirrors get_connection_params)
resolved_config_file = config_file
if environment and not resolved_config_file:
import os

resolved_config_file = os.environ.get("CALDAV_CONFIG_FILE")

resolved_section = config_section
if environment and not resolved_section:
import os

resolved_section = os.environ.get("CALDAV_CONFIG_SECTION")

all_params = _config.get_all_file_connection_params(resolved_config_file, resolved_section)
# The file and section variables (CALENDARING_CONFIG_*, CALDAV_CONFIG_*)
# are read by calendaring-config when environment is set
all_params = _config.get_all_file_connection_params(
config_file, config_section, environment=environment
)

if not all_params:
if raise_errors:
Expand Down
Loading
Loading