From fb123f93f9f5ce42c8e5785d2f8e0edaf951740e Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 26 Mar 2014 19:21:20 +0000 Subject: Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2. --- .../Main/webservice/samples/python/clienttest.py | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'src/VBox/Main/webservice/samples/python/clienttest.py') 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 = '' + 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 == '' 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() -- cgit v1.2.1