Add requests checking

This commit is contained in:
jpattWPC 2023-09-21 13:21:10 -05:00
parent e848a938df
commit b32d38338b
2 changed files with 35 additions and 30 deletions

2
dist/vdiclient.json vendored
View File

@ -1,6 +1,6 @@
{
"upgrade_guid" : "46cbad92-353e-4b28-9bee-83950991dad8",
"version" : "1.2.02",
"version" : "1.2.03",
"product_name" : "VDI Client",
"manufacturer" : "Josh Patten",
"name" : "VDI Client",

View File

@ -210,6 +210,9 @@ def getvms(listonly = False):
except proxmoxer.core.ResourceException as e:
win_popup_button(f"Unable to display list of VMs:\n {e!r}", 'OK')
return False
except requests.exceptions.ConnectionError as e:
print(f"Encountered error when querying proxmox: {e!r}")
return False
def setvmlayout(vms):
layout = []
@ -221,7 +224,6 @@ def setvmlayout(vms):
layoutcolumn = []
for vm in vms:
if not vm["status"] == "unknown":
print(vm)
vmkeyname = f'-VM|{vm["vmid"]}-'
connkeyname = f'-CONN|{vm["vmid"]}-'
resetkeyname = f'-RESET|{vm["vmid"]}-'
@ -521,9 +523,11 @@ def showvms():
if (datetime.now() - timer).total_seconds() > 5:
timer = datetime.now()
newvmlist = getvms(listonly = True)
if newvmlist:
if vmlist != newvmlist:
vmlist = newvmlist.copy()
vms = getvms()
if vms:
layout = setvmlayout(vms)
window.close()
if G.icon:
@ -533,6 +537,7 @@ def showvms():
window.bring_to_front()
else: # Refresh existing vm status
newvms = getvms()
if newvms:
for vm in newvms:
vmkeyname = f'-VM|{vm["vmid"]}-'
connkeyname = f'-CONN|{vm["vmid"]}-'