MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / run

Function run

tools/git_tools.py:29–55  ·  view source on GitHub ↗

Run a shell command with optional output capture and verbosity. Args: cmd (str | list): The command to run. cwd (str): The current working directory. verbose (bool): If True, print the command being run. **kwargs: Extra arguments passed to subprocess.run().

(cmd, verbose=False, **kwargs)

Source from the content-addressed store, hash-verified

27
28
29def run(cmd, verbose=False, **kwargs):
30 """
31 Run a shell command with optional output capture and verbosity.
32
33 Args:
34 cmd (str | list): The command to run.
35 cwd (str): The current working directory.
36 verbose (bool): If True, print the command being run.
37 **kwargs: Extra arguments passed to subprocess.run().
38
39 Returns:
40 str | None: If capture is True, returns the command's stdout as a string; otherwise None.
41 """
42 if verbose:
43 print(cmd if isinstance(cmd, str) else shlex.join(cmd))
44
45 result = subprocess.run(cmd,
46 shell=isinstance(cmd, str),
47 check=True,
48 capture_output=True,
49 text=True,
50 **kwargs).stdout.strip()
51
52 if verbose:
53 print(result)
54
55 return result
56
57
58def get_top():

Callers 7

clang_formatFunction · 0.90
yapf_formatFunction · 0.90
get_topFunction · 0.70
get_merge_baseFunction · 0.70
get_changed_filesFunction · 0.70
get_all_filesFunction · 0.70
get_latest_commit_yearFunction · 0.70

Calls 2

printFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected