summaryrefslogtreecommitdiff
path: root/src/VBox/Main/webservice/samples/python
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Main/webservice/samples/python')
-rw-r--r--src/VBox/Main/webservice/samples/python/Makefile2
-rw-r--r--src/VBox/Main/webservice/samples/python/Makefile.glue2
-rwxr-xr-xsrc/VBox/Main/webservice/samples/python/clienttest.py30
3 files changed, 25 insertions, 9 deletions
diff --git a/src/VBox/Main/webservice/samples/python/Makefile b/src/VBox/Main/webservice/samples/python/Makefile
index 7aa5cb3b..5e8a15bb 100644
--- a/src/VBox/Main/webservice/samples/python/Makefile
+++ b/src/VBox/Main/webservice/samples/python/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2008 Oracle Corporation
+# Copyright (C) 2008-2010 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/webservice/samples/python/Makefile.glue b/src/VBox/Main/webservice/samples/python/Makefile.glue
index 8465ca7b..102d5fb4 100644
--- a/src/VBox/Main/webservice/samples/python/Makefile.glue
+++ b/src/VBox/Main/webservice/samples/python/Makefile.glue
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2008 Oracle Corporation
+# Copyright (C) 2008-2010 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
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()