MCPcopy Index your code
hub / github.com/python/cpython / _read_output

Function _read_output

Lib/_osx_support.py:56–75  ·  view source on GitHub ↗

Output from successful command execution or None

(commandstring, capture_stderr=False)

Source from the content-addressed store, hash-verified

54
55
56def _read_output(commandstring, capture_stderr=False):
57 """Output from successful command execution or None"""
58 # Similar to os.popen(commandstring, "r").read(),
59 # but without actually using os.popen because that
60 # function is not usable during python bootstrap.
61 # tempfile is also not available then.
62 import contextlib
63 try:
64 import tempfile
65 fp = tempfile.NamedTemporaryFile()
66 except ImportError:
67 fp = open("/tmp/_osx_support.%s"%(
68 os.getpid(),), "w+b")
69
70 with contextlib.closing(fp) as fp:
71 if capture_stderr:
72 cmd = "%s >'%s' 2>&1" % (commandstring, fp.name)
73 else:
74 cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name)
75 return fp.read().decode('utf-8').strip() if not os.system(cmd) else None
76
77
78def _find_build_tool(toolname):

Callers 3

_find_build_toolFunction · 0.85
_default_sysrootFunction · 0.85

Calls 4

openFunction · 0.70
stripMethod · 0.45
decodeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…