Skip to content

Commit

Permalink
The New Computer Update (dammit arc!!!)
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianLucas committed Dec 21, 2023
1 parent d3d38e5 commit a756abf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
27 changes: 16 additions & 11 deletions interpreter/core/utils/system_debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,30 @@ def get_ram_info():
return f"{total_ram_gb:.2f} GB, used: {used_ram_gb:.2f}, free: {free_ram_gb:.2f}"


def get_package_mismatches(file_path='pyproject.toml'):
with open(file_path, 'r') as file:
def get_package_mismatches(file_path="pyproject.toml"):
with open(file_path, "r") as file:
pyproject = toml.load(file)
dependencies = pyproject['tool']['poetry']['dependencies']
dev_dependencies = pyproject['tool']['poetry']['group']['dev']['dependencies']
dependencies = pyproject["tool"]["poetry"]["dependencies"]
dev_dependencies = pyproject["tool"]["poetry"]["group"]["dev"]["dependencies"]
dependencies.update(dev_dependencies)

installed_packages = {pkg.key: pkg.version for pkg in pkg_resources.working_set}

mismatches = []
for package, version_info in dependencies.items():
if isinstance(version_info, dict):
version_info = version_info['version']
version_info = version_info["version"]
installed_version = installed_packages.get(package)
if installed_version and version_info.startswith('^'):
if installed_version and version_info.startswith("^"):
expected_version = version_info[1:]
if not installed_version.startswith(expected_version):
mismatches.append(f'\t {package}: Mismatch, pyproject.toml={expected_version}, pip={installed_version}')
mismatches.append(
f"\t {package}: Mismatch, pyproject.toml={expected_version}, pip={installed_version}"
)
else:
mismatches.append(f'\t {package}: Not found in pip list')
mismatches.append(f"\t {package}: Not found in pip list")

return '\n' + '\n'.join(mismatches)
return "\n" + "\n".join(mismatches)


def interpreter_info(interpreter):
Expand Down Expand Up @@ -129,8 +131,11 @@ def system_info(interpreter):
OS Version and Architecture: {get_os_version()}
CPU Info: {get_cpu_info()}
RAM Info: {get_ram_info()}
Package Version Mismatches:
{get_package_mismatches()}
{interpreter_info(interpreter)}
"""
)

# Removed the following, as it causes `FileNotFoundError: [Errno 2] No such file or directory: 'pyproject.toml'`` on prod
# (i think it works on dev, but on prod the pyproject.toml will not be in the cwd. might not be accessible at all)
# Package Version Mismatches:
# {get_package_mismatches()}
25 changes: 20 additions & 5 deletions interpreter/terminal_interface/start_terminal_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,12 @@ def start_terminal_interface(interpreter):
import cv2
import IPython
import matplotlib
import plyer
import pyautogui
import pytesseract
except ImportError:
display_markdown_message(
"> **Missing Packages**\n\nSeveral packages are required for OS Control (`matplotlib`, `pytesseract`, `pyautogui`, `opencv-python`, `ipython`).\n\nInstall them?\n"
"> **Missing Packages**\n\nSeveral packages are required for OS Control (`matplotlib`, `pytesseract`, `pyautogui`, `opencv-python`, `ipython`, `pyobjus`, `plyer`).\n\nInstall them?\n"
)
user_input = input("(y/n) > ")
if user_input.lower() != "y":
Expand All @@ -419,11 +420,25 @@ def start_terminal_interface(interpreter):
"pyautogui",
"opencv-python",
"ipython",
"plyer",
]
command = "\n".join([f"pip install {package}" for package in packages])
for chunk in interpreter.computer.run("shell", command):
if chunk.get("format") != "active_line":
print(chunk.get("content"))
for pip_name in ["pip", "pip3"]:
command = "\n".join(
[f"{pip_name} install {package}" for package in packages]
)
for chunk in interpreter.computer.run("shell", command):
if chunk.get("format") != "active_line":
print(chunk.get("content"))
try:
import cv2
import IPython
import matplotlib
import plyer
import pyautogui
import pytesseract
except:
continue
break

display_markdown_message(
"> `OS Control` enabled (experimental)\n\nOpen Interpreter will be able to see your screen, move your mouse, and use your keyboard."
Expand Down

0 comments on commit a756abf

Please sign in to comment.