From 6498b2771b5a977caf9c29d12846498cc4a506ea Mon Sep 17 00:00:00 2001 From: FredWuCZ Date: Fri, 27 Sep 2024 11:07:54 +0800 Subject: [PATCH] Update VM download link --- desktop_env/providers/docker/manager.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/desktop_env/providers/docker/manager.py b/desktop_env/providers/docker/manager.py index e1ebdb8..86fba12 100644 --- a/desktop_env/providers/docker/manager.py +++ b/desktop_env/providers/docker/manager.py @@ -25,7 +25,7 @@ logger.setLevel(logging.INFO) MAX_RETRY_TIMES = 10 RETRY_INTERVAL = 5 -UBUNTU_X86_URL = "https://huggingface.co/datasets/xlangai/ubuntu_osworld/resolve/main/Ubuntu-x86.zip" +UBUNTU_X86_URL = "https://huggingface.co/datasets/xlangai/ubuntu_osworld/resolve/main/Ubuntu.qcow2" # Determine the platform and CPU architecture to decide the correct VM image to download # if platform.system() == 'Darwin': # macOS @@ -117,13 +117,13 @@ def _install_vm(vm_name, vms_dir, downloaded_file_name, os_type, original_vm_nam logger.info("Download succeeds.") break # Download completed successfully - # Unzip the downloaded file - logger.info("Unzipping the downloaded file...☕️") - with zipfile.ZipFile(downloaded_file_path, 'r') as zip_ref: - zip_ref.extractall(os.path.join(vms_dir, vm_name)) - logger.info("Files have been successfully extracted to the directory: " + str(os.path.join(vms_dir, vm_name))) + vm_path = os.path.join(vms_dir, vm_name, vm_name + ".qcow2") - vm_path = os.path.join(vms_dir, vm_name, vm_name, vm_name + ".vmx") + # Execute the function to download and unzip the VM, and update the vm metadata + if not os.path.exists(vm_path): + __download_and_unzip_vm() + else: + logger.info(f"Virtual machine exists: {vm_path}") # Start the virtual machine def start_vm(vm_path, max_retries=20): @@ -272,8 +272,6 @@ class DockerVMManager(VMManager): for vm_path in vm_paths: if vm_name + ".qcow2" in vm_path: flag = False - elif vm_name + ".img" in vm_path: - flag = False if flag: shutil.rmtree(os.path.join(vms_dir, vm_name))