fix linter errors for config registry & cli (#2292)
This commit is contained in:
@@ -7,9 +7,9 @@ import time
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
import requests
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import requests
|
||||
import typer
|
||||
import uvicorn
|
||||
from dotenv import load_dotenv, set_key
|
||||
@@ -474,23 +474,23 @@ def setup_browser_config() -> tuple[str, Optional[str], Optional[str]]:
|
||||
print("\nTo use CDP connection, Chrome must be running with remote debugging enabled.")
|
||||
print("Example: chrome --remote-debugging-port=9222")
|
||||
print("Default debugging URL: http://localhost:9222")
|
||||
|
||||
default_port = "9222"
|
||||
|
||||
default_port = "9222"
|
||||
if remote_debugging_url is None:
|
||||
remote_debugging_url = "http://localhost:9222"
|
||||
elif ":" in remote_debugging_url.split("/")[-1]:
|
||||
default_port = remote_debugging_url.split(":")[-1].split("/")[0]
|
||||
|
||||
|
||||
parsed_url = urlparse(remote_debugging_url)
|
||||
version_url = f"{parsed_url.scheme}://{parsed_url.netloc}/json/version"
|
||||
|
||||
|
||||
print(f"\nChecking if Chrome is already running with remote debugging on port {default_port}...")
|
||||
try:
|
||||
response = requests.get(version_url, timeout=2)
|
||||
if response.status_code == 200:
|
||||
try:
|
||||
browser_info = response.json()
|
||||
print(f"Chrome is already running with remote debugging!")
|
||||
print("Chrome is already running with remote debugging!")
|
||||
if "Browser" in browser_info:
|
||||
print(f"Browser: {browser_info['Browser']}")
|
||||
if "webSocketDebuggerUrl" in browser_info:
|
||||
@@ -501,9 +501,9 @@ def setup_browser_config() -> tuple[str, Optional[str], Optional[str]]:
|
||||
print("Port is in use, but doesn't appear to be Chrome with remote debugging.")
|
||||
except requests.RequestException:
|
||||
print(f"No Chrome instance detected on {remote_debugging_url}")
|
||||
|
||||
|
||||
print("\nExecuting Chrome with remote debugging enabled:")
|
||||
|
||||
|
||||
if host_system == "darwin" or host_system == "linux":
|
||||
chrome_cmd = f'{browser_location} --remote-debugging-port={default_port} --user-data-dir="$HOME/chrome-cdp-profile" --no-first-run --no-default-browser-check'
|
||||
print(f" {chrome_cmd}")
|
||||
@@ -512,9 +512,11 @@ def setup_browser_config() -> tuple[str, Optional[str], Optional[str]]:
|
||||
print(f" {chrome_cmd}")
|
||||
else:
|
||||
print("Unsupported OS for Chrome configuration. Please set it up manually.")
|
||||
|
||||
|
||||
# Ask user if they want to execute the command
|
||||
execute_browser = input("\nWould you like to start Chrome with remote debugging now? (y/n) [y]: ").strip().lower()
|
||||
execute_browser = (
|
||||
input("\nWould you like to start Chrome with remote debugging now? (y/n) [y]: ").strip().lower()
|
||||
)
|
||||
if not execute_browser or execute_browser == "y":
|
||||
print(f"Starting Chrome with remote debugging on port {default_port}...")
|
||||
try:
|
||||
@@ -525,12 +527,12 @@ def setup_browser_config() -> tuple[str, Optional[str], Optional[str]]:
|
||||
subprocess.Popen(f"start {chrome_cmd}", shell=True)
|
||||
elif host_system == "wsl":
|
||||
subprocess.Popen(f"cmd.exe /c start {chrome_cmd}", shell=True)
|
||||
|
||||
|
||||
print(f"Chrome started successfully. Connecting to {remote_debugging_url}")
|
||||
|
||||
|
||||
print("Waiting for Chrome to initialize...")
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
try:
|
||||
verification_response = requests.get(version_url, timeout=5)
|
||||
if verification_response.status_code == 200:
|
||||
@@ -549,7 +551,7 @@ def setup_browser_config() -> tuple[str, Optional[str], Optional[str]]:
|
||||
except Exception as e:
|
||||
print(f"Error starting Chrome: {e}")
|
||||
print("Please start Chrome manually using the command above.")
|
||||
|
||||
|
||||
remote_debugging_url = input("Enter remote debugging URL (press Enter for default): ").strip()
|
||||
if not remote_debugging_url:
|
||||
remote_debugging_url = "http://localhost:9222"
|
||||
|
||||
Reference in New Issue
Block a user