VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxShell/xpcom/vboxshell.py@ 19239

Last change on this file since 19239 was 19239, checked in by vboxsync, 16 years ago

Main: support for using VBox from Python on Windows (still certain limitation apply, such as enum visibility)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1#!/usr/bin/python
2#
3#################################################################################
4# This program is a simple interactive shell for VirtualBox. You can query #
5# information and issue commands from a simple command line. #
6# #
7# It also provides you with examples on how to use VirtualBox's Python API. #
8# This shell is even somewhat documented and supports TAB-completion and #
9# history if you have Python readline installed. #
10# #
11# Enjoy. #
12#################################################################################
13#
14# To make it work, the following variables have to be set.
15# Please note the trailing slash in VBOX_PROGRAM_PATH - it's a must.
16#
17# This is the place where VirtualBox resides
18# export VBOX_PROGRAM_PATH=/opt/VirtualBox-2.0.0/
19# To allow Python find modules
20# export PYTHONPATH=../:$VBOX_PROGRAM_PATH
21#
22
23# this one has to be the first XPCOM related import
24import xpcom.vboxxpcom
25import xpcom
26import xpcom.components
27import sys, traceback
28
29from shellcommon import interpret
30
31class LocalManager:
32 def getSessionObject(self, vb):
33 return xpcom.components.classes["@virtualbox.org/Session;1"].createInstance()
34
35vbox = None
36mgr = LocalManager()
37try:
38 vbox = xpcom.components.classes["@virtualbox.org/VirtualBox;1"].createInstance()
39except xpcom.Exception, e:
40 print "XPCOM exception: ",e
41 traceback.print_exc()
42 sys.exit(1)
43
44ctx = {'mgr':mgr, 'vb':vbox, 'ifaces':xpcom.components.interfaces,
45 'remote':False, 'type':'xpcom' }
46
47interpret(ctx)
48
49del vbox
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette