VirtualBox

Ignore:
Timestamp:
Jun 21, 2010 4:49:59 PM (15 years ago)
Author:
vboxsync
Message:

Main: more events

File:
1 edited

Legend:

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

    r30280 r30345  
    426426        pass
    427427    vbox.unregisterCallback(cb)
     428
     429def monitorVBox2(ctx, dur):
     430    vbox = ctx['vb']
     431    print vbox.eventSource
     432    listener = vbox.eventSource.createListener()
     433    if dur == -1:
     434        # not infinity, but close enough
     435        dur = 100000
     436    try:
     437        vbox.eventSource.registerListener(listener, [ctx['global'].constants.VBoxEventType_All], False)
     438        end = time.time() + dur
     439        while  time.time() < end:
     440            ev = vbox.eventSource.getEvent(500)
     441            if ev:
     442                print "got event: %s %s" %(ev, str(ev.type))
     443    # We need to catch all exceptions here, otherwise callback will never be unregistered
     444    except:
     445        traceback.print_exc()
     446        pass
     447    vbox.eventSource.unregisterListener(listener)
    428448
    429449
     
    13871407        dur = float(args[1])
    13881408    monitorVBox(ctx, dur)
     1409    return 0
     1410
     1411def monitorVBox2Cmd(ctx, args):
     1412    if (len(args) > 2):
     1413        print "usage: monitorVBox2 (duration)"
     1414        return 0
     1415    dur = 5
     1416    if len(args) > 1:
     1417        dur = float(args[1])
     1418    monitorVBox2(ctx, dur)
    13891419    return 0
    13901420
     
    28562886            'monitorGuest':['Monitor what happens with the guest for some time: monitorGuest Win32 10', monitorGuestCmd, 0],
    28572887            'monitorVBox':['Monitor what happens with Virtual Box for some time: monitorVBox 10', monitorVBoxCmd, 0],
     2888            'monitorVBox2':['(temp)Monitor what happens with Virtual Box for some time: monitorVBox2 10', monitorVBox2Cmd, 0],
    28582889            'portForward':['Setup permanent port forwarding for a VM, takes adapter number host port and guest port: portForward Win32 0 8080 80', portForwardCmd, 0],
    28592890            'showLog':['Show log file of the VM, : showLog Win32', showLogCmd, 0],
Note: See TracChangeset for help on using the changeset viewer.

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