mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix(sandbox): ssh_box parsing (#1831)
* fix ssh_box error parsing * Add type check --------- Co-authored-by: Graham Neubig <neubig@gmail.com> Co-authored-by: OpenDevinBot <bot@opendevin.com>
This commit is contained in:
parent
b3a45ed7fe
commit
0cb707bc9d
@ -453,7 +453,7 @@ class DockerSSHBox(Sandbox):
|
||||
logger.debug(
|
||||
f'WAITING FOR END OF command output ({bool(output)}): {output}'
|
||||
)
|
||||
if output == '':
|
||||
if isinstance(output, str) and output.strip() == '':
|
||||
break
|
||||
command_output += output
|
||||
command_output = command_output.removesuffix('\r\n')
|
||||
@ -461,17 +461,19 @@ class DockerSSHBox(Sandbox):
|
||||
# get the exit code
|
||||
self.ssh.sendline('echo $?')
|
||||
self.ssh.prompt()
|
||||
exit_code_str = self.ssh.before
|
||||
exit_code_str = self.ssh.before.strip()
|
||||
_start_time = time.time()
|
||||
while not exit_code_str:
|
||||
self.ssh.prompt()
|
||||
exit_code_str = self.ssh.before
|
||||
self.ssh.prompt(timeout=1)
|
||||
exit_code_str = self.ssh.before.strip()
|
||||
logger.debug(f'WAITING FOR exit code: {exit_code_str}')
|
||||
if time.time() - _start_time > timeout:
|
||||
return self._send_interrupt(
|
||||
cmd, command_output, ignore_last_output=True
|
||||
)
|
||||
exit_code = int(exit_code_str.strip())
|
||||
exit_code = int(
|
||||
exit_code_str.replace('echo $?', '').replace('\r\n', '').strip()
|
||||
)
|
||||
return exit_code, command_output
|
||||
|
||||
def copy_to(self, host_src: str, sandbox_dest: str, recursive: bool = False):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user