(self, normalized_command: str)
| 387 | return "Output is too long. Parsed text output:\n" + text[:4000] |
| 388 | |
| 389 | def _execute_ssh(self, normalized_command: str) -> ShellCommandResult: |
| 390 | self._connect() |
| 391 | if self.session is None: |
| 392 | raise RuntimeError("No session available.") |
| 393 | |
| 394 | self._drain_pending_output() |
| 395 | |
| 396 | marker = f"{DEFAULT_MARKER_PREFIX}_{time.time_ns()}__" |
| 397 | wrapped_command = ( |
| 398 | f"{normalized_command}\n" |
| 399 | f"printf '\\n{marker}:%s\\n' $?\n" |
| 400 | ) |
| 401 | self.session.send(wrapped_command) |
| 402 | raw_output, timed_out = self._read_until_marker(marker) |
| 403 | |
| 404 | exit_code = self._extract_exit_code(raw_output, marker) |
| 405 | cleaned_output = self._strip_marker(raw_output, marker) |
| 406 | cleaned_output = self._trim_output(normalized_command, cleaned_output) |
| 407 | if timed_out: |
| 408 | cleaned_output = f"{cleaned_output}\nCommand execution timeout!" |
| 409 | |
| 410 | return ShellCommandResult( |
| 411 | command=normalized_command, |
| 412 | output=cleaned_output, |
| 413 | exit_code=exit_code, |
| 414 | timed_out=timed_out, |
| 415 | ) |
| 416 | |
| 417 | def _execute_local(self, normalized_command: str) -> ShellCommandResult: |
| 418 | try: |
no test coverage detected