MCPcopy Create free account
hub / github.com/OpenCCU/OpenCCU / _shell_fn

Function _shell_fn

buildroot-external/scripts/kconfiglib.py:6822–6848  ·  view source on GitHub ↗
(kconf, _, command)

Source from the content-addressed store, hash-verified

6820
6821
6822def _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

Callers

nothing calls this directly

Calls 2

_decoding_errorFunction · 0.85
_warnMethod · 0.80

Tested by

no test coverage detected