File: connectivity_test.py

package info (click to toggle)
python-aiohasupervisor 0.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 884 kB
  • sloc: python: 4,353; sh: 37; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 760 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Simple connectivity test."""

import asyncio
import json
import os
from typing import final

from aiohasupervisor import SupervisorClient
from aiohasupervisor.models import RootInfo

SUPERVISOR_API_URL: final = os.environ.get("SUPERVISOR_API_URL")
SUPERVISOR_TOKEN: final = os.environ.get("SUPERVISOR_TOKEN")

if not SUPERVISOR_API_URL:
    raise RuntimeError("SUPERVISOR_API_URL env must be set")
if not SUPERVISOR_TOKEN:
    raise RuntimeError("SUPERVISOR_TOKEN env must be set")

client = SupervisorClient(SUPERVISOR_API_URL, SUPERVISOR_TOKEN)


async def get_info() -> RootInfo:
    """Get root info."""
    async with client:
        return await client.info()


info = asyncio.run(get_info())
print(json.dumps(info.to_dict(), indent=4))  # noqa: T201