Run a shell command inside a container and return (rc, stdout, stderr). Unlike read_file/write_file this passes the command through sh -c so shell syntax (pipes, &&, redirects) works. Raises subprocess.TimeoutExpired on timeout — caller decides whether that's a tier failure or a hard er
(
container: str, command: str, timeout: int | None = None
)
| 123 | |
| 124 | |
| 125 | def exec_sh( |
| 126 | container: str, command: str, timeout: int | None = None |
| 127 | ) -> tuple[int, str, str]: |
| 128 | """Run a shell command inside a container and return (rc, stdout, stderr). |
| 129 | |
| 130 | Unlike read_file/write_file this passes the command through sh -c so shell |
| 131 | syntax (pipes, &&, redirects) works. Raises subprocess.TimeoutExpired on |
| 132 | timeout — caller decides whether that's a tier failure or a hard error. |
| 133 | """ |
| 134 | r = subprocess.run( |
| 135 | ["docker", "exec", container, "sh", "-c", command], |
| 136 | capture_output=True, |
| 137 | text=True, |
| 138 | errors="replace", |
| 139 | timeout=timeout, |
| 140 | ) |
| 141 | return r.returncode, r.stdout, r.stderr |
| 142 | |
| 143 | |
| 144 | def commit(container: str, tag: str) -> str: |
nothing calls this directly
no outgoing calls
no test coverage detected