MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / runv

Function runv

misc/python/materialize/spawn.py:35–84  ·  view source on GitHub ↗

Verbosely run a subprocess. A description of the subprocess will be written to stdout before the subprocess is executed. Args: args: A list of strings or paths describing the program to run and the arguments to pass to it. cwd: An optional directory to chang

(
    args: Sequence[Path | str],
    *,
    cwd: Path | None = None,
    env: dict[str, str] | None = None,
    stdin: None | int | IO[bytes] | bytes = None,
    stdout: None | int | IO[bytes] = None,
    stderr: None | int | IO[bytes] = None,
)

Source from the content-addressed store, hash-verified

33# set of parameters. If your needs are niche, consider calling `subprocess.run`
34# directly rather than adding a one-off parameter here.
35def runv(
36 args: Sequence[Path | str],
37 *,
38 cwd: Path | None = None,
39 env: dict[str, str] | None = None,
40 stdin: None | int | IO[bytes] | bytes = None,
41 stdout: None | int | IO[bytes] = None,
42 stderr: None | int | IO[bytes] = None,
43) -> subprocess.CompletedProcess:
44 """Verbosely run a subprocess.
45
46 A description of the subprocess will be written to stdout before the
47 subprocess is executed.
48
49 Args:
50 args: A list of strings or paths describing the program to run and
51 the arguments to pass to it.
52 cwd: An optional directory to change into before executing the process.
53 env: A replacement environment with which to launch the process. If
54 unspecified, the current process's environment is used. Replacement
55 occurs wholesale, so use a construction like
56 `env=dict(os.environ, KEY=VAL, ...)` to instead amend the existing
57 environment.
58 stdin: An optional IO handle or byte string to use as the process's
59 stdin stream.
60 stdout: An optional IO handle to use as the process's stdout stream.
61 stderr: An optional IO handle to use as the process's stderr stream.
62
63 Raises:
64 OSError: The process cannot be executed, e.g. because the specified
65 program does not exist.
66 CalledProcessError: The process exited with a non-zero exit status.
67 """
68 print("$", ui.shell_quote(args), file=sys.stderr)
69
70 input = None
71 if isinstance(stdin, bytes):
72 input = stdin
73 stdin = None
74
75 return subprocess.run(
76 args,
77 cwd=cwd,
78 env=env,
79 input=input,
80 stdin=stdin,
81 stdout=stdout,
82 stderr=stderr,
83 check=True,
84 )
85
86
87def capture(

Callers

nothing calls this directly

Calls 1

runMethod · 0.45

Tested by

no test coverage detected