ansible_gentooimgr/gentooimgr/command.py

15 lines
381 B
Python
Raw Permalink Normal View History

2023-12-21 18:53:25 +00:00
import sys
2023-12-26 00:06:43 +00:00
from subprocess import Popen, PIPE
2023-12-21 18:53:25 +00:00
import gentooimgr.chroot
def command(config, *args):
gentooimgr.chroot.bind()
for a in args:
proc = Popen(a, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
if proc.returncode != 0:
sys.stderr.write(f"{stderr}\n")
break
gentooimgr.chroot.unbind()