Skip to content

Commit 0cb707b

Browse files
xingyaowwneubigOpenDevinBot
authored
fix(sandbox): ssh_box parsing (All-Hands-AI#1831)
* fix ssh_box error parsing * Add type check --------- Co-authored-by: Graham Neubig <[email protected]> Co-authored-by: OpenDevinBot <[email protected]>
1 parent b3a45ed commit 0cb707b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

opendevin/runtime/docker/ssh_box.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,25 +453,27 @@ def execute(
453453
logger.debug(
454454
f'WAITING FOR END OF command output ({bool(output)}): {output}'
455455
)
456-
if output == '':
456+
if isinstance(output, str) and output.strip() == '':
457457
break
458458
command_output += output
459459
command_output = command_output.removesuffix('\r\n')
460460

461461
# get the exit code
462462
self.ssh.sendline('echo $?')
463463
self.ssh.prompt()
464-
exit_code_str = self.ssh.before
464+
exit_code_str = self.ssh.before.strip()
465465
_start_time = time.time()
466466
while not exit_code_str:
467-
self.ssh.prompt()
468-
exit_code_str = self.ssh.before
467+
self.ssh.prompt(timeout=1)
468+
exit_code_str = self.ssh.before.strip()
469469
logger.debug(f'WAITING FOR exit code: {exit_code_str}')
470470
if time.time() - _start_time > timeout:
471471
return self._send_interrupt(
472472
cmd, command_output, ignore_last_output=True
473473
)
474-
exit_code = int(exit_code_str.strip())
474+
exit_code = int(
475+
exit_code_str.replace('echo $?', '').replace('\r\n', '').strip()
476+
)
475477
return exit_code, command_output
476478

477479
def copy_to(self, host_src: str, sandbox_dest: str, recursive: bool = False):

0 commit comments

Comments
 (0)