mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 01:30:31 +08:00
advanced cmd options for streamer
This commit is contained in:
parent
a286cd5ec2
commit
386461c974
@ -73,6 +73,7 @@ from ..validators.os import valid_abs_path
|
|||||||
from ..validators.os import valid_abs_file
|
from ..validators.os import valid_abs_file
|
||||||
from ..validators.os import valid_abs_dir
|
from ..validators.os import valid_abs_dir
|
||||||
from ..validators.os import valid_unix_mode
|
from ..validators.os import valid_unix_mode
|
||||||
|
from ..validators.os import valid_options
|
||||||
from ..validators.os import valid_command
|
from ..validators.os import valid_command
|
||||||
|
|
||||||
from ..validators.net import valid_ip_or_host
|
from ..validators.net import valid_ip_or_host
|
||||||
@ -364,6 +365,8 @@ def _get_config_scheme() -> Dict:
|
|||||||
"process_name_prefix": Option("kvmd/streamer"),
|
"process_name_prefix": Option("kvmd/streamer"),
|
||||||
|
|
||||||
"cmd": Option(["/bin/true"], type=valid_command),
|
"cmd": Option(["/bin/true"], type=valid_command),
|
||||||
|
"cmd_remove": Option([], type=valid_options),
|
||||||
|
"cmd_append": Option([], type=valid_options),
|
||||||
},
|
},
|
||||||
|
|
||||||
"snapshot": {
|
"snapshot": {
|
||||||
|
|||||||
@ -132,6 +132,8 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
process_name_prefix: str,
|
process_name_prefix: str,
|
||||||
|
|
||||||
cmd: List[str],
|
cmd: List[str],
|
||||||
|
cmd_remove: List[str],
|
||||||
|
cmd_append: List[str],
|
||||||
|
|
||||||
**params_kwargs: Any,
|
**params_kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -148,7 +150,11 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
self.__process_name_prefix = process_name_prefix
|
self.__process_name_prefix = process_name_prefix
|
||||||
|
|
||||||
self.__cmd = cmd
|
self.__cmd = [
|
||||||
|
cmd[0], # Executable
|
||||||
|
*filter((lambda item: item not in cmd_remove), cmd[1:]),
|
||||||
|
*cmd_append,
|
||||||
|
]
|
||||||
|
|
||||||
self.__params = _StreamerParams(**params_kwargs)
|
self.__params = _StreamerParams(**params_kwargs)
|
||||||
|
|
||||||
|
|||||||
@ -94,8 +94,14 @@ def valid_unix_mode(arg: Any) -> int:
|
|||||||
return int(valid_number(arg, min=0, name="UNIX mode"))
|
return int(valid_number(arg, min=0, name="UNIX mode"))
|
||||||
|
|
||||||
|
|
||||||
|
def valid_options(arg: Any, name: str="") -> List[str]:
|
||||||
|
if not name:
|
||||||
|
name = "options"
|
||||||
|
return valid_string_list(arg, delim=r"[,\t]+", name=name)
|
||||||
|
|
||||||
|
|
||||||
def valid_command(arg: Any) -> List[str]:
|
def valid_command(arg: Any) -> List[str]:
|
||||||
cmd = valid_string_list(arg, delim=r"[,\t]+", name="command")
|
cmd = valid_options(arg, name="command")
|
||||||
if len(cmd) == 0:
|
if len(cmd) == 0:
|
||||||
raise_error(arg, "command")
|
raise_error(arg, "command")
|
||||||
cmd[0] = valid_abs_file(cmd[0], name="command entry point")
|
cmd[0] = valid_abs_file(cmd[0], name="command entry point")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user