64 lines
1.6 KiB
Python
64 lines
1.6 KiB
Python
import logging
|
|
import os
|
|
import platform
|
|
import subprocess
|
|
import time
|
|
import docker
|
|
|
|
from desktop_env.providers.base import Provider
|
|
|
|
logger = logging.getLogger("desktopenv.providers.vmware.VMwareProvider")
|
|
logger.setLevel(logging.INFO)
|
|
|
|
WAIT_TIME = 3
|
|
|
|
|
|
def get_vmrun_type(return_list=False):
|
|
if platform.system() == 'Windows' or platform.system() == 'Linux':
|
|
if return_list:
|
|
return ['-T', 'ws']
|
|
else:
|
|
return '-T ws'
|
|
elif platform.system() == 'Darwin': # Darwin is the system name for macOS
|
|
if return_list:
|
|
return ['-T', 'fusion']
|
|
else:
|
|
return '-T fusion'
|
|
else:
|
|
raise Exception("Unsupported operating system")
|
|
|
|
|
|
class DockerProvider(Provider):
|
|
def __init__(self, region: str):
|
|
self.client = docker.from_env()
|
|
|
|
@staticmethod
|
|
def _execute_command(command: list, return_output=False):
|
|
process = subprocess.Popen(
|
|
command,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
text=True,
|
|
encoding="utf-8"
|
|
)
|
|
|
|
if return_output:
|
|
output = process.communicate()[0].strip()
|
|
return output
|
|
else:
|
|
return None
|
|
|
|
def start_emulator(self, path_to_vm: str, headless: bool, os_type: str):
|
|
pass
|
|
|
|
def get_ip_address(self, path_to_vm: str) -> str:
|
|
pass
|
|
|
|
def save_state(self, path_to_vm: str, snapshot_name: str):
|
|
pass
|
|
|
|
def revert_to_snapshot(self, path_to_vm: str, snapshot_name: str):
|
|
pass
|
|
|
|
def stop_emulator(self, path_to_vm: str):
|
|
pass |