From e1e44d77c54a2f69dd187e7e6356553fd7df2e60 Mon Sep 17 00:00:00 2001 From: Timothyxxx <384084775@qq.com> Date: Thu, 16 May 2024 18:47:37 +0800 Subject: [PATCH] Improve the logic in auto-installation --- desktop_env/envs/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop_env/envs/__init__.py b/desktop_env/envs/__init__.py index 7f5baf6..b049d50 100644 --- a/desktop_env/envs/__init__.py +++ b/desktop_env/envs/__init__.py @@ -286,7 +286,7 @@ def _install_virtual_machine(vm_name, vms_dir, downloaded_file_name, original_vm def start_vm(vm_path, max_retries=20): command = f'vmrun {get_vmrun_type()} start "{vm_path}" nogui' for attempt in range(max_retries): - result = subprocess.run(command, shell=True, text=True, capture_output=True) + result = subprocess.run(command, shell=True, text=True, capture_output=True, encoding="utf-8") if result.returncode == 0: print("Virtual machine started.") return True @@ -306,7 +306,7 @@ def _install_virtual_machine(vm_name, vms_dir, downloaded_file_name, original_vm def get_vm_ip(vm_path, max_retries=20): command = f'vmrun {get_vmrun_type()} getGuestIPAddress "{vm_path}" -wait' for attempt in range(max_retries): - result = subprocess.run(command, shell=True, text=True, capture_output=True) + result = subprocess.run(command, shell=True, text=True, capture_output=True, encoding="utf-8") if result.returncode == 0: return result.stdout.strip() else: @@ -347,7 +347,7 @@ def _install_virtual_machine(vm_name, vms_dir, downloaded_file_name, original_vm def create_vm_snapshot(vm_path, max_retries=20): command = f'vmrun {get_vmrun_type()} snapshot "{vm_path}" "init_state"' for attempt in range(max_retries): - result = subprocess.run(command, shell=True, text=True, capture_output=True) + result = subprocess.run(command, shell=True, text=True, capture_output=True, encoding="utf-8") if result.returncode == 0: print("Snapshot created.") return True