(kconf, _, command)
| 6896 | |
| 6897 | |
| 6898 | def _shell_fn(kconf, _, command): |
| 6899 | import subprocess # Only import as needed, to save some startup time |
| 6900 | |
| 6901 | stdout, stderr = subprocess.Popen( |
| 6902 | command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE |
| 6903 | ).communicate() |
| 6904 | |
| 6905 | if not _IS_PY2: |
| 6906 | try: |
| 6907 | stdout = stdout.decode(kconf._encoding) |
| 6908 | stderr = stderr.decode(kconf._encoding) |
| 6909 | except UnicodeDecodeError as e: |
| 6910 | _decoding_error(e, kconf.filename, kconf.linenr) |
| 6911 | |
| 6912 | if stderr: |
| 6913 | kconf._warn("'{}' wrote to stderr: {}".format( |
| 6914 | command, "\n".join(stderr.splitlines())), |
| 6915 | kconf.filename, kconf.linenr) |
| 6916 | |
| 6917 | # Universal newlines with splitlines() (to prevent e.g. stray \r's in |
| 6918 | # command output on Windows), trailing newline removal, and |
| 6919 | # newline-to-space conversion. |
| 6920 | # |
| 6921 | # On Python 3 versions before 3.6, it's not possible to specify the |
| 6922 | # encoding when passing universal_newlines=True to Popen() (the 'encoding' |
| 6923 | # parameter was added in 3.6), so we do this manual version instead. |
| 6924 | return "\n".join(stdout.splitlines()).rstrip("\n").replace("\n", " ") |
| 6925 | |
| 6926 | # |
| 6927 | # Global constants |
nothing calls this directly
no test coverage detected