INNER CODE UNIT · Python

log_hostname_resolution

arnonym/ha-plugins · ha-sip/src/main.py:60

def log_hostname_resolution(label: str, url: str) -> None:
    if not url:
        return
    hostname = urlparse(url).hostname
    if not hostname:
        log(None, f'Error: could not extract hostname from {label}: {url}')
        return
    try:
        ip = socket.gethostbyname(hostname)
        log(None, f'{label} hostname {hostname} resolves to {ip}')
    except socket.gaierror as e:
        log(None, f'Error: could not resolve {label} hostname {hostname}: {e}')


def get_cache_dir(raw_cache_dir: str) -> Optional[str]:
    if not raw_cache_dir:
        log(None, 'No cache directory configured.')
        return None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…