MCPcopy Index your code
hub / github.com/python/cpython / _get_command_stdout

Function _get_command_stdout

Lib/uuid.py:424–452  ·  view source on GitHub ↗
(command, *args)

Source from the content-addressed store, hash-verified

422
423
424def _get_command_stdout(command, *args):
425 import io, os, shutil, subprocess
426
427 try:
428 path_dirs = os.environ.get('PATH', os.defpath).split(os.pathsep)
429 path_dirs.extend(['/sbin', '/usr/sbin'])
430 executable = shutil.which(command, path=os.pathsep.join(path_dirs))
431 if executable is None:
432 return None
433 # LC_ALL=C to ensure English output, stderr=DEVNULL to prevent output
434 # on stderr (Note: we don't have an example where the words we search
435 # for are actually localized, but in theory some system could do so.)
436 env = dict(os.environ)
437 env['LC_ALL'] = 'C'
438 # Empty strings will be quoted by popen so we should just omit it
439 if args != ('',):
440 command = (executable, *args)
441 else:
442 command = (executable,)
443 proc = subprocess.Popen(command,
444 stdout=subprocess.PIPE,
445 stderr=subprocess.DEVNULL,
446 env=env)
447 if not proc:
448 return None
449 stdout, stderr = proc.communicate()
450 return io.BytesIO(stdout)
451 except (OSError, subprocess.SubprocessError):
452 return None
453
454
455# 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…