diff --git a/desktop_env/controllers/setup.py b/desktop_env/controllers/setup.py index baac70d..4dd5eaf 100644 --- a/desktop_env/controllers/setup.py +++ b/desktop_env/controllers/setup.py @@ -47,11 +47,12 @@ class SetupController: self.http_server: str = f"http://{vm_ip}:{server_port}" self.http_server_setup_root: str = f"http://{vm_ip}:{server_port}/setup" self.cache_dir: str = cache_dir + self.use_proxy: bool = False def reset_cache_dir(self, cache_dir: str): self.cache_dir = cache_dir - def setup(self, config: List[Dict[str, Any]])-> bool: + def setup(self, config: List[Dict[str, Any]], use_proxy: bool = False)-> bool: """ Args: config (List[Dict[str, Any]]): list of dict like {str: Any}. each @@ -63,6 +64,7 @@ class SetupController: parameters } """ + self.use_proxy = use_proxy # make sure connection can be established logger.info(f"try to connect {self.http_server}") retry = 0 @@ -237,6 +239,9 @@ class SetupController: if not shell and isinstance(command, str) and len(command.split()) > 1: logger.warning("Command should be a list of strings. Now it is a string. Will split it by space.") command = command.split() + + if command[0] == "google-chrome" and self.use_proxy: + command.append("--proxy-server=http://127.0.0.1:18888") # Use the proxy server set up by _proxy_setup payload = json.dumps({"command": command, "shell": shell}) headers = {"Content-Type": "application/json"} diff --git a/desktop_env/desktop_env.py b/desktop_env/desktop_env.py index 72c955c..c7d53f1 100644 --- a/desktop_env/desktop_env.py +++ b/desktop_env/desktop_env.py @@ -203,7 +203,7 @@ class DesktopEnv(gym.Env): self._set_task_info(task_config) self.setup_controller.reset_cache_dir(self.cache_dir) logger.info("Setting up environment...") - success = self.setup_controller.setup(self.config) + success = self.setup_controller.setup(self.config, task_config.get("proxy", False) and self.enable_proxy) if success: break else: diff --git a/evaluation_examples/examples/multi_apps/5990457f-2adb-467b-a4af-5c857c92d762.json b/evaluation_examples/examples/multi_apps/5990457f-2adb-467b-a4af-5c857c92d762.json index 6a3e3de..695a9d2 100644 --- a/evaluation_examples/examples/multi_apps/5990457f-2adb-467b-a4af-5c857c92d762.json +++ b/evaluation_examples/examples/multi_apps/5990457f-2adb-467b-a4af-5c857c92d762.json @@ -9,7 +9,6 @@ "parameters": { "command": [ "google-chrome", - "--proxy-server=http://127.0.0.1:18888", "--remote-debugging-port=1337" ] }