mirror of
https://github.com/trycua/computer.git
synced 2026-04-29 19:52:35 -05:00
Fixed broken winsandbox_example, added venv to provider setup
This commit is contained in:
@@ -423,7 +423,7 @@ class WinSandboxProvider(BaseVMProvider):
|
||||
if total_attempts % 10 == 0:
|
||||
self.logger.info(f"Still waiting for Windows Sandbox {name} IP after {total_attempts} attempts...")
|
||||
|
||||
async def _setup_computer_server(self, sandbox, name: str, visible: bool = False):
|
||||
async def _setup_computer_server(self, sandbox, name: str, visible: bool = True):
|
||||
"""Setup the computer server in the Windows Sandbox using RPyC.
|
||||
|
||||
Args:
|
||||
@@ -472,8 +472,8 @@ class WinSandboxProvider(BaseVMProvider):
|
||||
shell=False
|
||||
)
|
||||
|
||||
# # Sleep for 30 seconds
|
||||
# await asyncio.sleep(30)
|
||||
# Sleep for 30 seconds
|
||||
await asyncio.sleep(30)
|
||||
|
||||
ip = await self.get_ip(name)
|
||||
self.logger.info(f"Sandbox IP: {ip}")
|
||||
|
||||
@@ -79,23 +79,38 @@ try {
|
||||
$pythonVersion = & $pythonExe --version 2>&1
|
||||
Write-Host "Python version: $pythonVersion"
|
||||
|
||||
# Step 2: Install cua-computer-server directly
|
||||
Write-Host "Step 2: Installing cua-computer-server..."
|
||||
# Step 2: Create a dedicated virtual environment for the sandbox
|
||||
Write-Host "Step 2: Creating virtual environment (if needed)..."
|
||||
$venvPath = "C:\Users\WDAGUtilityAccount\venv"
|
||||
if (!(Test-Path $venvPath)) {
|
||||
Write-Host "Creating venv at: $venvPath"
|
||||
& $pythonExe -m venv $venvPath
|
||||
} else {
|
||||
Write-Host "Venv already exists at: $venvPath"
|
||||
}
|
||||
$venvPython = Join-Path $venvPath "Scripts\python.exe"
|
||||
if (!(Test-Path $venvPython)) {
|
||||
throw "Virtual environment Python not found at $venvPython"
|
||||
}
|
||||
Write-Host "Using venv Python: $venvPython"
|
||||
|
||||
# Step 3: Install cua-computer-server into the venv
|
||||
Write-Host "Step 3: Installing cua-computer-server..."
|
||||
|
||||
Write-Host "Upgrading pip..."
|
||||
& $pythonExe -m pip install --upgrade pip --quiet
|
||||
& $venvPython -m pip install --upgrade pip --quiet
|
||||
|
||||
Write-Host "Installing cua-computer-server..."
|
||||
& $pythonExe -m pip install cua-computer-server --quiet
|
||||
& $venvPython -m pip install cua-computer-server
|
||||
|
||||
Write-Host "cua-computer-server installation completed."
|
||||
|
||||
# Step 3: Start computer server in background
|
||||
Write-Host "Step 3: Starting computer server in background..."
|
||||
Write-Host "Starting computer server with: $pythonExe"
|
||||
# Step 4: Start computer server in background using the venv Python
|
||||
Write-Host "Step 4: Starting computer server in background..."
|
||||
Write-Host "Starting computer server with: $venvPython"
|
||||
|
||||
# Start the computer server in the background
|
||||
$serverProcess = Start-Process -FilePath $pythonExe -ArgumentList "-m", "computer_server.main" -WindowStyle Hidden -PassThru
|
||||
$serverProcess = Start-Process -FilePath $venvPython -ArgumentList "-m", "computer_server.main" -WindowStyle Hidden -PassThru
|
||||
Write-Host "Computer server started in background with PID: $($serverProcess.Id)"
|
||||
|
||||
# Give it a moment to start
|
||||
|
||||
Reference in New Issue
Block a user