VirtualBox

Changeset 20693 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 18, 2009 4:37:00 PM (15 years ago)
Author:
vboxsync
Message:

Python: Windows waiting for event, additional shell command

File:
1 edited

Legend:

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

    r20630 r20693  
    156156    def onShowWindow(self, winId):
    157157        print  "%s: onShowWindow: %d" %(self.mach.name, winId)
     158
     159class VBoxMonitor:
     160    def __init__(self, vbox):
     161        self.vbox = vbox
     162        pass
     163
     164    def onMachineStateChange(self, id, state):
     165        print "onMachineStateChange: %s %d" %(id, state)
     166
     167    def onMachineDataChange(self,id):
     168        print "onMachineDataChange: %s" %(id)
     169   
     170    def onExtraDataCanChange(self, id, key, value):
     171        print "onExtraDataCanChange: %s %s=>%s" %(id, key, value)
     172        return true
     173
     174    def onExtraDataChange(self, id, key, value):
     175        print "onExtraDataChange: %s %s=>%s" %(id, key, value)
     176
     177    def onMediaRegistred(self, id, type, registred):
     178        print "onMediaRegistred: %s" %(id)
     179
     180    def onMachineRegistred(self, id, registred):
     181        print "onMachineRegistred: %s" %(id)
     182
     183    def onSessionStateChange(self, id, state):
     184        print "onSessionStateChange: %s %d" %(id, state)
     185
     186    def onSnapshotTaken(self, mach, id):
     187        print "onSnapshotTaken: %s %s" %(mach, id)
     188
     189    def onSnapshotDiscarded(self, mach, id):
     190        print "onSnapshotDiscarded: %s %s" %(mach, id)
     191
     192    def onSnapshotChange(self, mach, id):
     193        print "onSnapshotChange: %s %s" %(mach, id)
     194
     195    def onGuestPropertyChange(self, id, val1, val2, val3):
     196        print "onGuestPropertyChange: %s" %(id)
     197   
     198
    158199
    159200g_hasreadline = 1
     
    304345def monitorGuest(ctx, machine, console, dur):
    305346    import time
    306     import xpcom
    307347    cb = ctx['global'].createCallback('IConsoleCallback', GuestMonitor, machine)
    308348    console.registerCallback(cb)
     
    319359    console.unregisterCallback(cb)
    320360
    321    
     361
     362def monitorVbox(ctx, dur):
     363    import time
     364    vbox = ctx['vb']
     365    cb = ctx['global'].createCallback('IVirtualBoxCallback', VBoxMonitor, vbox)
     366    vbox.registerCallback(cb)
     367    if dur == -1:
     368        # not infinity, but close enough
     369        dur = 100000
     370    try:
     371        end = time.time() + dur
     372        while  time.time() < end:
     373            ctx['global'].waitForEvents(500)
     374    # We need to catch all exceptions here, otherwise callback will never be unregistered
     375    except Exception,e:
     376        print e
     377        if g_verbose:
     378                traceback.print_exc()
     379        pass   
     380    vbox.unregisterCallback(cb)
    322381
    323382def cmdExistingVm(ctx,mach,cmd,args):
     
    561620    return 0
    562621
     622def monitorVboxCmd(ctx, args):
     623    if (len(args) > 2):
     624        print "usage: monitorVbox (duration)"
     625        return 0
     626    dur = 5
     627    if len(args) > 1:
     628        dur = float(args[1])
     629    monitorVbox(ctx, dur)
     630    return 0
     631
    563632def evalCmd(ctx, args):
    564633   expr = ' '.join(args[1:])
     
    597666            'guest':['Execute command for guest: guest Win32 console.mouse.putMouseEvent(20, 20, 0, 0)', guestCmd],
    598667            'monitorGuest':['Monitor what happens with the guest for some time: monitorGuest Win32 10', monitorGuestCmd],
     668            'monitorVbox':['Monitor what happens with Virtual Box for some time: monitorVbox 10', monitorVboxCmd],
    599669            }
    600670
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