Xingyao Wang 1 жил өмнө
parent
commit
9e59937180

+ 8 - 6
opendevin/runtime/docker/ssh_box.py

@@ -292,7 +292,9 @@ class DockerSSHBox(Sandbox):
 
 
     def start_ssh_session(self):
     def start_ssh_session(self):
         # start ssh session at the background
         # start ssh session at the background
-        self.ssh = pxssh.pxssh(echo=False, timeout=self.timeout)
+        self.ssh = pxssh.pxssh(
+            echo=False, timeout=self.timeout, encoding='utf-8', codec_errors='replace'
+        )
         hostname = self.ssh_hostname
         hostname = self.ssh_hostname
         if self.run_as_devin:
         if self.run_as_devin:
             username = 'opendevin'
             username = 'opendevin'
@@ -336,7 +338,7 @@ class DockerSSHBox(Sandbox):
         self.ssh.prompt()
         self.ssh.prompt()
         command_output = prev_output
         command_output = prev_output
         if not ignore_last_output:
         if not ignore_last_output:
-            command_output += '\n' + self.ssh.before.decode('utf-8')
+            command_output += '\n' + self.ssh.before
         return (
         return (
             -1,
             -1,
             f'Command: "{cmd}" timed out. Sending SIGINT to the process: {command_output}',
             f'Command: "{cmd}" timed out. Sending SIGINT to the process: {command_output}',
@@ -361,7 +363,7 @@ class DockerSSHBox(Sandbox):
         if not success:
         if not success:
             logger.exception('Command timed out, killing process...', exc_info=False)
             logger.exception('Command timed out, killing process...', exc_info=False)
             return self._send_interrupt(cmd)
             return self._send_interrupt(cmd)
-        command_output = self.ssh.before.decode('utf-8')
+        command_output = self.ssh.before
 
 
         # once out, make sure that we have *every* output, we while loop until we get an empty output
         # once out, make sure that we have *every* output, we while loop until we get an empty output
         while True:
         while True:
@@ -372,7 +374,7 @@ class DockerSSHBox(Sandbox):
                 logger.debug('TIMEOUT REACHED')
                 logger.debug('TIMEOUT REACHED')
                 break
                 break
             logger.debug('WAITING FOR .before')
             logger.debug('WAITING FOR .before')
-            output = self.ssh.before.decode('utf-8')
+            output = self.ssh.before
             logger.debug(
             logger.debug(
                 f'WAITING FOR END OF command output ({bool(output)}): {output}'
                 f'WAITING FOR END OF command output ({bool(output)}): {output}'
             )
             )
@@ -384,11 +386,11 @@ class DockerSSHBox(Sandbox):
         # get the exit code
         # get the exit code
         self.ssh.sendline('echo $?')
         self.ssh.sendline('echo $?')
         self.ssh.prompt()
         self.ssh.prompt()
-        exit_code_str = self.ssh.before.decode('utf-8')
+        exit_code_str = self.ssh.before
         _start_time = time.time()
         _start_time = time.time()
         while not exit_code_str:
         while not exit_code_str:
             self.ssh.prompt()
             self.ssh.prompt()
-            exit_code_str = self.ssh.before.decode('utf-8')
+            exit_code_str = self.ssh.before
             logger.debug(f'WAITING FOR exit code: {exit_code_str}')
             logger.debug(f'WAITING FOR exit code: {exit_code_str}')
             if time.time() - _start_time > timeout:
             if time.time() - _start_time > timeout:
                 return self._send_interrupt(
                 return self._send_interrupt(