Finish Chrome example loading v1

This commit is contained in:
Timothyxxx
2024-01-13 22:56:50 +08:00
parent bc88ee0c41
commit a1c3e4c294
13 changed files with 351 additions and 43 deletions

View File

@@ -280,3 +280,31 @@ class PythonController:
else:
logger.error("Failed to get wallpaper. Status code: %d", response.status_code)
return None
def get_vm_desktop_path(self):
"""
Gets the desktop path of the vm.
"""
response = requests.post(self.http_server + "/desktop_path")
if response.status_code == 200:
logger.info("Desktop path downloaded successfully")
return response.json()["desktop_path"]
else:
logger.error("Failed to get desktop path. Status code: %d", response.status_code)
return None
def get_vm_directory_tree(self, path):
"""
Gets the directory tree of the vm.
"""
payload = json.dumps({"path": path})
headers = {
'Content-Type': 'application/json'
}
response = requests.post(self.http_server + "/list_directory", headers=headers, data=payload)
if response.status_code == 200:
logger.info("Directory tree downloaded successfully")
return response.json()["directory_tree"]
else:
logger.error("Failed to get directory tree. Status code: %d", response.status_code)
return None