Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.41 KB

README.md

File metadata and controls

49 lines (34 loc) · 1.41 KB

python-nanokvm

Async Python client for the Sipeed NanoKVM and NanoKVM Pro.

pip install nanokvm

Usage

import asyncio
from pathlib import Path

from nanokvm.client import NanoKVMClient
from nanokvm.models import GpioType, MouseButton


async def main() -> None:
    async with NanoKVMClient("https://kvm.local/api/") as client:
        await client.authenticate("username", "password")

        await client.push_button(GpioType.POWER, duration_ms=1000)
        await client.paste_text("Hello\nworld!")
        await client.mouse_click(MouseButton.LEFT, 0.5, 0.5)

        Path("screen.jpg").write_bytes(await client.get_snapshot())


asyncio.run(main())

The client detects the hardware and firmware, and raises NanoKVMNotSupportedError instead of calling an endpoint the device lacks.

Scripts that do not use asyncio can use the same API as blocking calls through nanokvm.sync_client.NanoKVMSyncClient.

Documentation