Skip to content

Commit

Permalink
Render terminal output everywhere -- including exit code, was failing…
Browse files Browse the repository at this point in the history
… for google colab env
  • Loading branch information
Aman Rusia committed Oct 26, 2024
1 parent ac95a4d commit 1c1d515
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
authors = [{ name = "Aman Rusia", email = "[email protected]" }]
name = "wcgw"
version = "0.1.1"
version = "0.1.2"
description = "What could go wrong giving full shell access to chatgpt?"
readme = "README.md"
requires-python = ">=3.10, <3.13"
Expand Down
7 changes: 4 additions & 3 deletions src/wcgw/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def _get_exit_code() -> int:
while not _is_int(before): # Consume all previous output
SHELL.expect("#@@")
assert isinstance(SHELL.before, str)
before = SHELL.before
# Render because there could be some anscii escape sequences still set like in google colab env
before = render_terminal_output(SHELL.before).strip()

try:
return int((before))
Expand Down Expand Up @@ -285,7 +286,7 @@ def read_image_from_shell(file_path: str) -> ImageData:
SHELL.sendline("pwd")
SHELL.expect("#@@")
assert isinstance(SHELL.before, str)
current_dir = SHELL.before.strip()
current_dir = render_terminal_output(SHELL.before).strip()
file_path = os.path.join(current_dir, file_path)

if not os.path.exists(file_path):
Expand All @@ -304,7 +305,7 @@ def write_file(writefile: Writefile) -> str:
SHELL.sendline("pwd")
SHELL.expect("#@@")
assert isinstance(SHELL.before, str)
current_dir = SHELL.before.strip()
current_dir = render_terminal_output(SHELL.before).strip()
return f"Failure: Use absolute path only. FYI current working directory is '{current_dir}'"
os.makedirs(os.path.dirname(writefile.file_path), exist_ok=True)
try:
Expand Down

0 comments on commit 1c1d515

Please sign in to comment.