summaryrefslogtreecommitdiff
path: root/kvmd/validators
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-07-13 04:10:26 +0300
committerDevaev Maxim <[email protected]>2020-07-14 09:04:52 +0300
commit77f3dab55c52859490619825ace4620a5d134901 (patch)
tree90ac48b6cb5108543f9f3bad423c8a05de0e1ace /kvmd/validators
parent07fb731b215a560bdc0a89a1fd5c199d910034a3 (diff)
optional quality and resolution
Diffstat (limited to 'kvmd/validators')
-rw-r--r--kvmd/validators/kvm.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py
index cf63b97e..b32a785e 100644
--- a/kvmd/validators/kvm.py
+++ b/kvmd/validators/kvm.py
@@ -24,8 +24,10 @@ from typing import Any
from ..keyboard.mappings import KEYMAP
+from . import raise_error
from . import check_string_in_list
+from .basic import valid_stripped_string_not_empty
from .basic import valid_number
from .os import valid_printable_filename
@@ -56,6 +58,17 @@ def valid_stream_fps(arg: Any) -> int:
return int(valid_number(arg, min=0, max=120, name="stream FPS"))
+def valid_stream_resolution(arg: Any) -> str:
+ name = "stream resolution"
+ arg = valid_stripped_string_not_empty(arg, name)
+ parts = arg.split("x")
+ if len(parts) != 2:
+ raise_error(arg, name)
+ width = int(valid_number(parts[0], min=1, name=f"{name} (width)"))
+ height = int(valid_number(parts[1], min=1, name=f"{name} (height)"))
+ return f"{width}x{height}"
+
+
# =====
def valid_hid_key(arg: Any) -> str:
return check_string_in_list(arg, "HID key", KEYMAP, lower=False)