MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / run_command

Function run_command

diffusers/benchmarks/run_all.py:19–33  ·  view source on GitHub ↗

Runs `command` with `subprocess.check_output` and will potentially return the `stdout`. Will also properly capture if an error occurred while running `command`

(command: List[str], return_stdout=False)

Source from the content-addressed store, hash-verified

17
18# Taken from `test_examples_utils.py`
19def run_command(command: List[str], return_stdout=False):
20 """
21 Runs `command` with `subprocess.check_output` and will potentially return the `stdout`. Will also properly capture
22 if an error occurred while running `command`
23 """
24 try:
25 output = subprocess.check_output(command, stderr=subprocess.STDOUT)
26 if return_stdout:
27 if hasattr(output, "decode"):
28 output = output.decode("utf-8")
29 return output
30 except subprocess.CalledProcessError as e:
31 raise SubprocessCallException(
32 f"Command `{' '.join(command)}` failed with the following error:\n\n{e.output.decode()}"
33 ) from e
34
35
36def main():

Callers 1

mainFunction · 0.70

Calls 2

decodeMethod · 0.45

Tested by

no test coverage detected