diff options
Diffstat (limited to 'src/VBox/Main/webservice/samples/python/clienttest.py')
-rwxr-xr-x | src/VBox/Main/webservice/samples/python/clienttest.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/VBox/Main/webservice/samples/python/clienttest.py b/src/VBox/Main/webservice/samples/python/clienttest.py index 50e5d103..bcb2b815 100755 --- a/src/VBox/Main/webservice/samples/python/clienttest.py +++ b/src/VBox/Main/webservice/samples/python/clienttest.py @@ -37,6 +37,7 @@ def enumToString(constants, enum, elem): def main(argv): from vboxapi import VirtualBoxManager + # This is a VirtualBox COM/XPCOM API client, no data needed. wrapper = VirtualBoxManager(None, None) # Get the VirtualBox manager @@ -50,12 +51,27 @@ def main(argv): vboxConstants = wrapper.constants # Enumerate all defined machines - for mach in vbox.machines: + for mach in wrapper.getArray(vbox, 'machines'): try: - - # Print some basic information - print "Machine name: %s [%s]" %(mach.name,mach.id) + # Be prepared for failures - the VM can be inaccessible + vmname = '<inaccessible>' + try: + vmname = mach.name + except Exception, e: + None + vmid = ''; + try: + vmid = mach.id + except Exception, e: + None + + # Print some basic VM information even if there were errors + print "Machine name: %s [%s]" %(vmname,vmid) + if vmname == '<inaccessible>' or vmid == '': + continue + + # Print some basic VM information print " State: %s" %(enumToString(vboxConstants, "MachineState", mach.state)) print " Session state: %s" %(enumToString(vboxConstants, "SessionState", mach.sessionState)) @@ -82,10 +98,10 @@ def main(argv): # Get the VM's display object display = console.display - # Get the VM's current display resolution + bit depth + # Get the VM's current display resolution + bit depth + position screenNum = 0 # From first screen - (screenX, screenY, screenBPP) = display.getScreenResolution(screenNum) - print " Display (%d): %dx%d, %d BPP" %(screenNum, screenX, screenY, screenBPP) + (screenW, screenH, screenBPP, screenX, screenY) = display.getScreenResolution(screenNum) + print " Display (%d): %dx%d, %d BPP at %d,%d" %(screenNum, screenW, screenH, screenBPP, screenX, screenY) # We're done -- don't forget to unlock the machine! session.unlockMachine() |