Improve the logic in auto-installation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user