MCPcopy Index your code
hub / github.com/RustPython/RustPython / _read_output

Function _read_output

Lib/_osx_support.py:55–74  ·  view source on GitHub ↗

Output from successful command execution or None

(commandstring, capture_stderr=False)

Source from the content-addressed store, hash-verified

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

Callers 3

_find_build_toolFunction · 0.85
_default_sysrootFunction · 0.85

Calls 5

closingMethod · 0.80
openFunction · 0.70
stripMethod · 0.45
decodeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected