MCPcopy Create free account
hub / github.com/Dizzy-K/AutoPT / _execute_ssh

Method _execute_ssh

tools/terminal.py:389–415  ·  view source on GitHub ↗
(self, normalized_command: str)

Source from the content-addressed store, hash-verified

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:

Callers 1

executeMethod · 0.95

Calls 7

_connectMethod · 0.95
_drain_pending_outputMethod · 0.95
_read_until_markerMethod · 0.95
_extract_exit_codeMethod · 0.95
_strip_markerMethod · 0.95
_trim_outputMethod · 0.95
ShellCommandResultClass · 0.85

Tested by

no test coverage detected