List command for manylinux images

This commit is contained in:
Valentin Niess
2023-11-08 18:06:02 +01:00
parent db5d91e0dd
commit e596fec38b
3 changed files with 56 additions and 3 deletions

View File

@@ -4,11 +4,12 @@ import stat
import subprocess
import sys
from .compat import decode
from .log import log
from .system import system
def docker_run(image, extra_cmds):
def docker_run(image, extra_cmds, capture=False):
'''Execute commands within a docker container
'''
@@ -42,10 +43,16 @@ def docker_run(image, extra_cmds):
'type=bind,source={:},target=/pwd'.format(os.getcwd()),
image, '/bin/bash', bash_arg))
if capture:
opts = {'stderr': subprocess.PIPE, 'stdout': subprocess.PIPE}
else:
opts = {}
log('RUN', image)
p = subprocess.Popen(cmd, shell=True)
p.communicate()
p = subprocess.Popen(cmd, shell=True, **opts)
r = p.communicate()
if p.returncode != 0:
if p.returncode == 139:
sys.stderr.write("segmentation fault when running Docker (139)\n")
sys.exit(p.returncode)
if capture:
return decode(r[0])