clienttest.py revision 8e77372da4b53557362ee8ea967def86f7bed166
#
# Copyright (C) 2012 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# Things needed to be set up before running this sample:
# - Install Python and verify it works (2.7.2 will do, 3.x is untested yet)
# - On Windows: Install the PyWin32 extensions for your Python version
# - If not already done, set the environment variable "VBOX_INSTALL_PATH"
# to point to your VirtualBox installation directory (which in turn must have
# the "sdk" subfolder")
# - Install the VirtualBox Python bindings by doing a
# "[python] vboxapisetup.py install"
# - Run this sample with "[python] clienttest.py"
import traceback
#
# Converts an enumeration to a printable string.
#
return e
return "<unknown>"
from vboxapi import VirtualBoxManager
wrapper = VirtualBoxManager(None, None)
# Get the VirtualBox manager
# Get the global VirtualBox object
# Get all constants through the Python wrapper code
# Enumerate all defined machines
try:
# Print some basic information
# Do some stuff which requires a running VM
# Get the session object
# Lock the current machine (shared mode, since we won't modify the machine)
# Acquire the VM's console and guest object
# Retrieve the current Guest Additions runlevel and print
# the installed Guest Additions version
# Get the VM's display object
# Get the VM's current display resolution + bit depth
# We're done -- don't forget to unlock the machine!
except Exception, e:
# Call destructor and delete wrapper
del wrapper
if __name__ == '__main__':