Output from successful command execution or None
(commandstring, capture_stderr=False)
| 54 | |
| 55 | |
| 56 | def _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 | |
| 78 | def _find_build_tool(toolname): |
no test coverage detected
searching dependent graphs…