ahvn.utils.basic.cmd_utils module¶
- ahvn.utils.basic.cmd_utils.cmd(command, wait=True, shell=True, sudo=False, include=None, **kwargs)[源代码]¶
Run a command and return requested items.
- 参数:
wait (
bool) -- whether to wait for the process to finish.shell (
bool) -- pass to subprocess.Popen.sudo (
bool) -- prepend sudo to the command.include (
Union[List[Literal['handle','stdout','stderr','returncode']],str,None]) -- list of keys to return. Default ["handle"]. Supported keys: "handle" (the Popen object), "stdout", "stderr", "returncode".
- 返回类型:
- 返回:
If include == ["handle"] (default) returns the Popen object. If len(include) > 1 returns a dict mapping requested keys to values. If stdout/stderr are requested, they are captured via PIPE (unless provided in kwargs). If wait is False and stdout/stderr/returncode are requested, their values will be None (caller can read from process.stdout / process.stderr or wait later).