MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / run_command

Function run_command

examples/test_examples_utils.py:31–45  ·  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

29
30
31def run_command(command: List[str], return_stdout=False):
32 """
33 Runs `command` with `subprocess.check_output` and will potentially return the `stdout`. Will also properly capture
34 if an error occurred while running `command`
35 """
36 try:
37 output = subprocess.check_output(command, stderr=subprocess.STDOUT)
38 if return_stdout:
39 if hasattr(output, "decode"):
40 output = output.decode("utf-8")
41 return output
42 except subprocess.CalledProcessError as e:
43 raise SubprocessCallException(
44 f"Command `{' '.join(command)}` failed with the following error:\n\n{e.output.decode()}"
45 ) from e
46
47
48class ExamplesTestsAccelerate(unittest.TestCase):

Calls 2

decodeMethod · 0.45

Tested by

no test coverage detected