VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxShell/mscom/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#!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#
15
16import sys, os
17from win32com import universal
18from win32com.client import gencache, DispatchWithEvents, Dispatch
19from win32com.client import constants, getevents
20import win32com.server.register
21import win32com
22import pythoncom
23import win32api
24import traceback
25
26from shellcommon import interpret
27
28class LocalManager:
29 def getSessionObject(self, vb):
30 return win32com.client.Dispatch("{3C02F46D-C9D2-4f11-A384-53F0CF917214}")
31
32vbox = None
33mgr = LocalManager()
34try:
35 vbox = win32com.client.Dispatch("{B1A7A4F2-47B9-4A1E-82B2-07CCD5323C3F}")
36except Exception,e:
37 print "COM exception: ",e
38 traceback.print_exc()
39 sys.exit(1)
40
41# fake constants, while get resolved constants issues for real
42# win32com.client.constants doesn't work for some reasons
43class DummyInterfaces: pass
44class SessionState:pass
45
46DummyInterfaces.SessionState=SessionState()
47DummyInterfaces.SessionState.Open = 2
48
49ctx = {'mgr':mgr, 'vb':vbox, 'ifaces':DummyInterfaces(),
50#'ifaces':win32com.client.constants,
51 'remote':False, 'type':'mscom' }
52
53interpret(ctx)
54
55del vbox
Note: See TracBrowser for help on using the repository browser.

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