Skip to content

SystemResource

SystemResource

System information and logs for PiKVM.

Source code in src/aiopikvm/resources/system.py
class SystemResource(BaseResource):
    """System information and logs for PiKVM."""

    async def get_info(self, *fields: str) -> dict[str, Any]:
        """Get general device information.

        Args:
            *fields: Optional category filters (``"auth"``, ``"extras"``,
                ``"fan"``, ``"hw"``, ``"meta"``, ``"system"``).
                When omitted, all categories are returned.

        Returns:
            Dictionary with device information grouped by category.
        """
        params: dict[str, Any] | None = None
        if fields:
            params = {"fields": list(fields)}
        result: dict[str, Any] = await self._get("/api/info", params=params)
        return result

    async def get_log(self, *, seek: int = 0) -> str:
        """Get KVMD service logs.

        Args:
            seek: How many seconds of history to return (``0`` = default).

        Returns:
            Log output as plain text.
        """
        params: dict[str, int] = {}
        if seek > 0:
            params["seek"] = seek
        response = await self._get_raw(
            "/api/log", accept="text/plain", params=params if params else None
        )
        return response.text

    async def stream_log(self, *, seek: int = 0) -> AsyncIterator[str]:
        """Stream KVMD service logs in real time.

        Uses ``follow=1`` to keep the connection open and yield new
        log lines as they arrive.

        Args:
            seek: How many seconds of history to return (``0`` = default).

        Yields:
            Individual log lines as they arrive.
        """
        params: dict[str, Any] = {"follow": 1}
        if seek > 0:
            params["seek"] = seek
        async with self._client.stream(
            "GET",
            "/api/log",
            params=params,
            headers={"Accept": "text/plain"},
            timeout=httpx.Timeout(self._client._timeout, read=None),
        ) as response:
            async for line in response.aiter_lines():
                yield line

get_info(*fields) async

Get general device information.

Parameters:

Name Type Description Default
*fields str

Optional category filters ("auth", "extras", "fan", "hw", "meta", "system"). When omitted, all categories are returned.

()

Returns:

Type Description
dict[str, Any]

Dictionary with device information grouped by category.

Source code in src/aiopikvm/resources/system.py
async def get_info(self, *fields: str) -> dict[str, Any]:
    """Get general device information.

    Args:
        *fields: Optional category filters (``"auth"``, ``"extras"``,
            ``"fan"``, ``"hw"``, ``"meta"``, ``"system"``).
            When omitted, all categories are returned.

    Returns:
        Dictionary with device information grouped by category.
    """
    params: dict[str, Any] | None = None
    if fields:
        params = {"fields": list(fields)}
    result: dict[str, Any] = await self._get("/api/info", params=params)
    return result

get_log(*, seek=0) async

Get KVMD service logs.

Parameters:

Name Type Description Default
seek int

How many seconds of history to return (0 = default).

0

Returns:

Type Description
str

Log output as plain text.

Source code in src/aiopikvm/resources/system.py
async def get_log(self, *, seek: int = 0) -> str:
    """Get KVMD service logs.

    Args:
        seek: How many seconds of history to return (``0`` = default).

    Returns:
        Log output as plain text.
    """
    params: dict[str, int] = {}
    if seek > 0:
        params["seek"] = seek
    response = await self._get_raw(
        "/api/log", accept="text/plain", params=params if params else None
    )
    return response.text

stream_log(*, seek=0) async

Stream KVMD service logs in real time.

Uses follow=1 to keep the connection open and yield new log lines as they arrive.

Parameters:

Name Type Description Default
seek int

How many seconds of history to return (0 = default).

0

Yields:

Type Description
AsyncIterator[str]

Individual log lines as they arrive.

Source code in src/aiopikvm/resources/system.py
async def stream_log(self, *, seek: int = 0) -> AsyncIterator[str]:
    """Stream KVMD service logs in real time.

    Uses ``follow=1`` to keep the connection open and yield new
    log lines as they arrive.

    Args:
        seek: How many seconds of history to return (``0`` = default).

    Yields:
        Individual log lines as they arrive.
    """
    params: dict[str, Any] = {"follow": 1}
    if seek > 0:
        params["seek"] = seek
    async with self._client.stream(
        "GET",
        "/api/log",
        params=params,
        headers={"Accept": "text/plain"},
        timeout=httpx.Timeout(self._client._timeout, read=None),
    ) as response:
        async for line in response.aiter_lines():
            yield line