Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/agent_env/env/envs/computer/utils/site_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import hashlib
import json
import os
import pwd
import re
import shutil
import socket
Expand All @@ -41,6 +40,11 @@
from typing import Optional
from urllib.parse import urlsplit, urlunsplit

try:
import pwd
except ImportError: # Windows, which agent-env does not target, imports is_local and matches from here on its host.
pwd = None

HOSTS_BEGIN = "# agentenv sites"
HOSTS_END = "# end agentenv sites"
LOOPBACK = "127.0.0.1"
Expand Down
7 changes: 7 additions & 0 deletions tst/unit/env/envs/test_computer_site_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import socket
import ssl
import struct
import subprocess
import sys
import urllib.error
from datetime import timedelta
Expand Down Expand Up @@ -984,6 +985,12 @@ def missing(name):
assert (Config.load(str(serve_path)).user, Config.load(str(serve_path)).serve_user) == ("agent", "nobody")


def test_the_proxy_imports_when_pwd_is_unavailable():
subprocess.run([sys.executable, "-c", "import sys; sys.modules['pwd'] = None; "
"from agent_env.env.envs.computer.utils import site_proxy, sites; assert site_proxy.pwd is None"],
check=True)


def test_keep_starts_serve_again_each_time_it_ends(monkeypatch):
runs = []

Expand Down
Loading