subprocess-util/exec_capture.py

13 lines
327 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import subprocess
def execute_capture(command: list[str]) -> [int, str, str]:
completed: subprocess.CompletedProcess = subprocess.run(
command,
capture_output=True,
text=True,
)
return completed.returncode, completed.stdout, completed.stderr