VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/sample/vboxshell.py@ 12972

最後變更 在這個檔案從12972是 12137,由 vboxsync 提交於 16 年 前
  • simplified running instructions
  • 屬性 svn:eol-style 設為 native
檔案大小: 1.8 KB
 
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, 'remote':False}
45
46interpret(ctx)
47
48del vbox
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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