debug
This commit is contained in:
@@ -36,8 +36,16 @@ def _run_shell(command: list[str], timeout: int = 20) -> subprocess.CompletedPro
|
|||||||
return subprocess.run(command, capture_output=True, text=True, timeout=timeout)
|
return subprocess.run(command, capture_output=True, text=True, timeout=timeout)
|
||||||
|
|
||||||
|
|
||||||
def _run_systemctl(command: list[str], timeout: int = 20, require_sudo: bool = True) -> subprocess.CompletedProcess[str]:
|
def _run_systemctl(
|
||||||
systemctl_command = ["systemctl", *command]
|
command: list[str],
|
||||||
|
timeout: int = 20,
|
||||||
|
require_sudo: bool = True,
|
||||||
|
no_block: bool = False,
|
||||||
|
) -> subprocess.CompletedProcess[str]:
|
||||||
|
systemctl_command = ["systemctl"]
|
||||||
|
if no_block and "--no-block" not in command:
|
||||||
|
systemctl_command.append("--no-block")
|
||||||
|
systemctl_command.extend(command)
|
||||||
if os.geteuid() == 0 or not require_sudo:
|
if os.geteuid() == 0 or not require_sudo:
|
||||||
return _run_shell(systemctl_command, timeout=timeout)
|
return _run_shell(systemctl_command, timeout=timeout)
|
||||||
return _run_shell(["sudo", "-n", *systemctl_command], timeout=timeout)
|
return _run_shell(["sudo", "-n", *systemctl_command], timeout=timeout)
|
||||||
|
|||||||
Reference in New Issue
Block a user