diff options
author | Devaev Maxim <[email protected]> | 2020-05-23 15:57:02 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-05-23 15:57:02 +0300 |
commit | e9d86c058d715af343be355b1ab3d58b7eed43b9 (patch) | |
tree | 6ae712152e4e9d7c274c5e369755f7030269677e /kvmd/clients | |
parent | a795fe5ed63b960cbf24c9130ed37f9f7f33280c (diff) |
major keymaps improvement
Diffstat (limited to 'kvmd/clients')
-rw-r--r-- | kvmd/clients/kvmd.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/kvmd/clients/kvmd.py b/kvmd/clients/kvmd.py index 678f104e..5e44811b 100644 --- a/kvmd/clients/kvmd.py +++ b/kvmd/clients/kvmd.py @@ -22,7 +22,9 @@ import contextlib +from typing import Tuple from typing import Dict +from typing import Set from typing import AsyncGenerator import aiohttp @@ -90,11 +92,18 @@ class _StreamerClientPart(_BaseClientPart): class _HidClientPart(_BaseClientPart): - async def print(self, user: str, passwd: str, text: str, limit: int) -> None: + async def get_keymaps(self, user: str, passwd: str) -> Tuple[str, Set[str]]: + async with self._make_session(user, passwd) as session: + async with session.get(self._make_url("hid/keymaps")) as response: + aiotools.raise_not_200(response) + result = (await response.json())["result"] + return (result["keymaps"]["default"], set(result["keymaps"]["available"])) + + async def print(self, user: str, passwd: str, text: str, limit: int, keymap_name: str) -> None: async with self._make_session(user, passwd) as session: async with session.post( url=self._make_url("hid/print"), - params={"limit": limit}, + params={"limit": limit, "keymap": keymap_name}, data=text, ) as response: aiotools.raise_not_200(response) |