INNER CODE UNIT · Python
_run
LINBIT/linstor-server · scripts/linstor-controller-ha-setup.py:130
def _run(cmd, check=False, capture=False):
"""subprocess.run for Python 3.6 and up.
RHEL 8 ships Python 3.6, where `capture_output` and `text` do not exist
yet (both are 3.7). Their long-hand equivalents work everywhere, so this
script sticks to those rather than requiring a newer interpreter on the
node it is meant to fix.
"""
pipe = subprocess.PIPE if capture else None
return subprocess.run(cmd, check=check, universal_newlines=True,
stdout=pipe, stderr=pipe)
def run(cmd, check=True, capture=False):
print("+ " + " ".join(cmd), flush=True)
return _run(cmd, check=check, capture=capture)