#!/usr/bin/python # # Copyright (C) 2009 Sun Microsystems, Inc. # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # 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. # # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa # Clara, CA 95054 USA or visit http://www.sun.com if you need # additional information or have any questions. # # ################################################################################# # This program is a simple interactive shell for VirtualBox. You can query # # information and issue commands from a simple command line. # # # # It also provides you with examples on how to use VirtualBox's Python API. # # This shell is even somewhat documented and supports TAB-completion and # # history if you have Python readline installed. # # # # Enjoy. # ################################################################################ import os,sys import traceback from vboxapi import VirtualBoxManager from shellcommon import interpret def main(argv): style = None if len(argv) > 1: if argv[1] == "-w": style = "WEBSERVICE" g_virtualBoxManager = VirtualBoxManager(style, None) ctx = {'global':g_virtualBoxManager, 'mgr':g_virtualBoxManager.mgr, 'vb':g_virtualBoxManager.vbox, 'ifaces':g_virtualBoxManager.constants, 'remote':g_virtualBoxManager.remote, 'type':g_virtualBoxManager.type } interpret(ctx) del g_virtualBoxManager if __name__ == '__main__': main(sys.argv)