VirtualBox

Ignore:
Timestamp:
Apr 28, 2009 1:19:14 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
46627
Message:

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

Location:
trunk/src/VBox/Frontends/VBoxShell
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxShell/mscom/vboxshell.py

    r18705 r19239  
    3939    sys.exit(1)
    4040
    41 ctx = {'mgr':mgr, 'vb':vbox, 'ifaces':win32com.client.constants,
    42        'remote':False, 'perf':PerfCollector(vbox) }
     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' }
    4352
    4453interpret(ctx)
  • trunk/src/VBox/Frontends/VBoxShell/shellcommon.py

    r18693 r19239  
    177177        # we ignore exceptions to allow starting VM even if
    178178        # perf collector cannot be started
    179         try:
     179        if perf:
     180          try:
    180181            perf.setup(['*'], [mach], 10, 15)
    181         except:
     182          except Exception,e:
    182183            print e
    183184            if g_verbose:
     
    192193
    193194def getMachines(ctx):
    194     return ctx['vb'].getMachines()
     195    # XPCOM brigde has trouble with array attributes
     196    if ctx['type'] == 'xpcom':
     197       return ctx['vb'].getMachines()
     198    else:
     199       return ctx['vb'].machines
    195200
    196201def asState(var):
     
    201206
    202207def guestStats(ctx,mach):
     208    if not ctx['perf']:
     209        return
    203210    for metric in ctx['perf'].query(["*"], [mach]):
    204211        print metric['name'], metric['values_as_string']
     
    427434      print "Processor #%d speed: %dMHz" %(i,host.getProcessorSpeed(i))
    428435
    429    for metric in ctx['perf'].query(["*"], [host]):
     436   if ctx['perf']:
     437     for metric in ctx['perf'].query(["*"], [host]):
    430438       print metric['name'], metric['values_as_string']
    431439
     
    488496    print "Running VirtualBox version %s" %(vbox.version)
    489497
    490     ctx['perf'] = PerfCollector(vbox)
     498    # MSCOM doesn't work with collector yet
     499    if ctx['type'] != 'mscom':
     500       ctx['perf'] = PerfCollector(vbox)
     501    else:
     502       ctx['perf'] = None
    491503
    492504    autoCompletion(commands, ctx)
     
    494506    # to allow to print actual host information, we collect info for
    495507    # last 150 secs maximum, (sample every 10 secs and keep up to 15 samples)
    496     try:
     508    if ctx['perf']:
     509      try:
    497510        ctx['perf'].setup(['*'], [vbox.host], 10, 15)
    498     except:
     511      except:
    499512        pass
    500513
     
    516529    try:
    517530        # There is no need to disable metric collection. This is just an example.
    518         ctx['perf'].disable(['*'], [vbox.host])
     531        if ct['perf']:
     532           ctx['perf'].disable(['*'], [vbox.host])
    519533    except:
    520534        pass
  • trunk/src/VBox/Frontends/VBoxShell/ws/vboxshell.py

    r18693 r19239  
    3232
    3333ctx = {'mgr':mgr, 'vb':vbox, 'ifaces': g_reflectionInfo, 'remote': True,
    34        'perf':PerfCollector(vbox)}
     34       'type':'ws'}
    3535
    3636interpret(ctx)
  • trunk/src/VBox/Frontends/VBoxShell/xpcom/vboxshell.py

    r18705 r19239  
    4343
    4444ctx = {'mgr':mgr, 'vb':vbox, 'ifaces':xpcom.components.interfaces,
    45        'remote':False, 'perf':PerfCollector(vbox)}
     45       'remote':False, 'type':'xpcom' }
    4646
    4747interpret(ctx)
Note: See TracChangeset for help on using the changeset viewer.

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