MCPcopy Create free account
hub / github.com/apache/burr / _run_command

Function _run_command

scripts/apache_release.py:83–120  ·  view source on GitHub ↗

Run a subprocess command with consistent error handling and output. Args: cmd: Command and arguments as list description: What we're doing (printed before running) error_message: Error message prefix if command fails success_message: Optional success message (pri

(
    cmd: list[str],
    description: str,
    error_message: str,
    success_message: Optional[str] = None,
    capture_output: bool = True,
    **kwargs,
)

Source from the content-addressed store, hash-verified

81
82
83def _run_command(
84 cmd: list[str],
85 description: str,
86 error_message: str,
87 success_message: Optional[str] = None,
88 capture_output: bool = True,
89 **kwargs,
90) -> subprocess.CompletedProcess:
91 """Run a subprocess command with consistent error handling and output.
92
93 Args:
94 cmd: Command and arguments as list
95 description: What we're doing (printed before running)
96 error_message: Error message prefix if command fails
97 success_message: Optional success message (printed after if provided)
98 capture_output: Whether to capture stdout/stderr (default True)
99 **kwargs: Additional arguments to pass to subprocess.run
100
101 Returns:
102 CompletedProcess instance
103 """
104 if description:
105 print(f" {description}")
106
107 try:
108 result = subprocess.run(
109 cmd,
110 check=True,
111 capture_output=capture_output,
112 text=True,
113 **kwargs,
114 )
115 if success_message:
116 print(f" ✓ {success_message}")
117 return result
118 except subprocess.CalledProcessError as e:
119 error_detail = f": {e.stderr}" if capture_output and e.stderr else ""
120 _fail(f"{error_message}{error_detail}")
121
122
123# ============================================================================

Callers 5

_sign_artifactFunction · 0.85
_create_git_archiveFunction · 0.85
_build_sdist_from_gitFunction · 0.85
_build_ui_artifactsFunction · 0.85

Calls 2

_failFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected