MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / _shell_fn

Function _shell_fn

scripts/kconfig/kconfiglib.py:6898–6924  ·  view source on GitHub ↗
(kconf, _, command)

Source from the content-addressed store, hash-verified

6896
6897
6898def _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

Callers

nothing calls this directly

Calls 2

_decoding_errorFunction · 0.85
_warnMethod · 0.80

Tested by

no test coverage detected