Fix output strip behavior discrepancy among sandboxes (#1355)

This commit is contained in:
Boxuan Li 2024-04-24 23:38:01 -07:00 committed by GitHub
parent 5543fe2c3e
commit c45e2ae4d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -122,7 +122,7 @@ class DockerExecBox(Sandbox):
self.container.exec_run(
f'kill -9 {pid}', workdir=SANDBOX_WORKSPACE_DIR)
return -1, f'Command: "{cmd}" timed out'
return exit_code, logs.decode('utf-8')
return exit_code, logs.decode('utf-8').strip()
def copy_to(self, host_src: str, sandbox_dest: str, recursive: bool = False):
# mkdir -p sandbox_dest if it doesn't exist

View File

@ -35,7 +35,7 @@ class LocalBox(Sandbox):
cmd, shell=True, text=True, capture_output=True,
timeout=self.timeout, cwd=config.get('WORKSPACE_BASE')
)
return completed_process.returncode, completed_process.stdout
return completed_process.returncode, completed_process.stdout.strip()
except subprocess.TimeoutExpired:
return -1, 'Command timed out'