MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _get_command_stdout

Function _get_command_stdout

tools/python-3.11.9-amd64/Lib/uuid.py:360–388  ·  view source on GitHub ↗
(command, *args)

Source from the content-addressed store, hash-verified

358
359
360def _get_command_stdout(command, *args):
361 import io, os, shutil, subprocess
362
363 try:
364 path_dirs = os.environ.get('PATH', os.defpath).split(os.pathsep)
365 path_dirs.extend(['/sbin', '/usr/sbin'])
366 executable = shutil.which(command, path=os.pathsep.join(path_dirs))
367 if executable is None:
368 return None
369 # LC_ALL=C to ensure English output, stderr=DEVNULL to prevent output
370 # on stderr (Note: we don't have an example where the words we search
371 # for are actually localized, but in theory some system could do so.)
372 env = dict(os.environ)
373 env['LC_ALL'] = 'C'
374 # Empty strings will be quoted by popen so we should just ommit it
375 if args != ('',):
376 command = (executable, *args)
377 else:
378 command = (executable,)
379 proc = subprocess.Popen(command,
380 stdout=subprocess.PIPE,
381 stderr=subprocess.DEVNULL,
382 env=env)
383 if not proc:
384 return None
385 stdout, stderr = proc.communicate()
386 return io.BytesIO(stdout)
387 except (OSError, subprocess.SubprocessError):
388 return None
389
390
391# For MAC (a.k.a. IEEE 802, or EUI-48) addresses, the second least significant

Callers 2

_find_mac_near_keywordFunction · 0.85
_find_mac_under_headingFunction · 0.85

Calls 5

communicateMethod · 0.95
splitMethod · 0.45
getMethod · 0.45
extendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected