MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / cmd_output_b

Function cmd_output_b

pre_commit/util.py:90–113  ·  view source on GitHub ↗
(
        *cmd: str,
        check: bool = True,
        **kwargs: Any,
)

Source from the content-addressed store, hash-verified

88
89
90def cmd_output_b(
91 *cmd: str,
92 check: bool = True,
93 **kwargs: Any,
94) -> tuple[int, bytes, bytes | None]:
95 _setdefault_kwargs(kwargs)
96
97 try:
98 cmd = parse_shebang.normalize_cmd(cmd, env=kwargs.get('env'))
99 except parse_shebang.ExecutableNotFoundError as e:
100 returncode, stdout_b, stderr_b = e.to_output()
101 else:
102 try:
103 proc = subprocess.Popen(cmd, **kwargs)
104 except OSError as e:
105 returncode, stdout_b, stderr_b = _oserror_to_output(e)
106 else:
107 stdout_b, stderr_b = proc.communicate()
108 returncode = proc.returncode
109
110 if check and returncode:
111 raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
112
113 return returncode, stdout_b, stderr_b
114
115
116def cmd_output(*cmd: str, **kwargs: Any) -> tuple[int, str, str | None]:

Callers 15

_log_and_exitFunction · 0.90
setup_cmdFunction · 0.90
_git_applyFunction · 0.90
has_diffFunction · 0.90
has_core_hookpaths_setFunction · 0.90
init_repoFunction · 0.90
commitFunction · 0.90
_git_cmdMethod · 0.90
health_checkFunction · 0.90
install_environmentFunction · 0.90
install_environmentFunction · 0.90

Calls 5

_setdefault_kwargsFunction · 0.85
_oserror_to_outputFunction · 0.85
CalledProcessErrorClass · 0.85
to_outputMethod · 0.80
getMethod · 0.45

Tested by 6

_norm_pwdFunction · 0.72
_create_repo_with_tagsFunction · 0.72
_ensure_image_availableFunction · 0.72