(kconf, _, command)
| 6820 | |
| 6821 | |
| 6822 | def _shell_fn(kconf, _, command): |
| 6823 | import subprocess # Only import as needed, to save some startup time |
| 6824 | |
| 6825 | stdout, stderr = subprocess.Popen( |
| 6826 | command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE |
| 6827 | ).communicate() |
| 6828 | |
| 6829 | if not _IS_PY2: |
| 6830 | try: |
| 6831 | stdout = stdout.decode(kconf._encoding) |
| 6832 | stderr = stderr.decode(kconf._encoding) |
| 6833 | except UnicodeDecodeError as e: |
| 6834 | _decoding_error(e, kconf.filename, kconf.linenr) |
| 6835 | |
| 6836 | if stderr: |
| 6837 | kconf._warn("'{}' wrote to stderr: {}".format( |
| 6838 | command, "\n".join(stderr.splitlines())), |
| 6839 | kconf.filename, kconf.linenr) |
| 6840 | |
| 6841 | # Universal newlines with splitlines() (to prevent e.g. stray \r's in |
| 6842 | # command output on Windows), trailing newline removal, and |
| 6843 | # newline-to-space conversion. |
| 6844 | # |
| 6845 | # On Python 3 versions before 3.6, it's not possible to specify the |
| 6846 | # encoding when passing universal_newlines=True to Popen() (the 'encoding' |
| 6847 | # parameter was added in 3.6), so we do this manual version instead. |
| 6848 | return "\n".join(stdout.splitlines()).rstrip("\n").replace("\n", " ") |
| 6849 | |
| 6850 | # |
| 6851 | # Global constants |
nothing calls this directly
no test coverage detected