Allow full command output for OpenWrt
This commit is contained in:
@@ -22,3 +22,24 @@ async def run_cmd(cmd: list[str], *, use_restic_env: bool = False, timeout: int
|
||||
except asyncio.TimeoutError:
|
||||
proc.kill()
|
||||
return 124, "❌ timeout"
|
||||
|
||||
|
||||
async def run_cmd_full(cmd: list[str], *, use_restic_env: bool = False, timeout: int = 60):
|
||||
env = os.environ.copy()
|
||||
env["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
if use_restic_env:
|
||||
env.update(RESTIC_ENV)
|
||||
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
*cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.STDOUT,
|
||||
env=env,
|
||||
)
|
||||
|
||||
try:
|
||||
out, _ = await asyncio.wait_for(proc.communicate(), timeout=timeout)
|
||||
return proc.returncode, out.decode(errors="ignore")
|
||||
except asyncio.TimeoutError:
|
||||
proc.kill()
|
||||
return 124, "❌ timeout"
|
||||
|
||||
Reference in New Issue
Block a user