INNER CODE UNIT · Python
check_output
mongodb/mongo-cxx-driver · etc/calc_release_version.py:114
def check_output(args): # type: (list[str]) -> str
"""
Delegates to subprocess.check_output() if it is available, otherwise
provides a reasonable facsimile.
"""
debug('Run command: {0}'.format(args))
try:
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
except OSError as e:
suppl = ''
if e.errno == errno.ENOENT:
suppl = 'Does the executable “{0}” not exist?'.format(args[0])
raise RuntimeError("Failed to execute subprocess {0}: {1} [{2}]".format(args, e, suppl))
out = proc.communicate()[0]
ret = proc.poll()
if ret:
raise subprocess.CalledProcessError(ret, args[0])