in common.py [0:0]
def check_execute(command, timeout=None,
sandbox_profile=None, max_retries=1,
stdout=sys.stdout, stderr=sys.stderr,
**kwargs):
"""Check execute a given command.
>>> check_execute(['echo', 'Hello, World!'])
0
"""
if timeout is None:
timeout = DEFAULT_EXECUTE_TIMEOUT
if sandbox_profile:
if platform.system() == 'Darwin':
command = ['sandbox-exec', '-f', sandbox_profile] + command
elif platform.system() == 'Linux':
# TODO: remove explicit dns after Firejail bug is resolved
command = ['firejail', '--quiet', '--profile=%s' % sandbox_profile,
'--private=.', '--overlay-tmpfs',
'--dns=8.8.8.8'] + command
returncode = -1
for retry in range(max_retries):
returncode = execute(command, timeout=timeout,
stdout=stdout, stderr=stderr,
**kwargs)
if returncode == 0:
return returncode
raise ExecuteCommandFailure(command, returncode)