Changeset 20598 in vbox for trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
- Timestamp:
- Jun 15, 2009 6:08:09 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r20332 r20598 96 96 }) 97 97 return out 98 99 # Simple implementation of IConsoleCallback, one can use it as skeleton 100 # for custom implementations 101 class GuestMonitor: 102 def __init__(self, mach): 103 self.mach = mach 104 105 def onMousePointerShapeChange(self, visible, alpha, xHot, yHot, width, height, shape): 106 print "%s: onMousePointerShapeChange: visible=%d" %(self.mach.name, visible) 107 def onMouseCapabilityChange(self, supportsAbsolute, needsHostCursor): 108 print "%s: onMouseCapabilityChange: needsHostCursor=%d" %(self.mach.name, needsHostCursor) 109 110 def onKeyboardLedsChange(self, numLock, capsLock, scrollLock): 111 print "%s: onKeyboardLedsChange capsLock=%d" %(self.mach.name, capsLock) 112 113 def onStateChange(self, state): 114 print "%s: onStateChange state=%d" %(self.mach.name, state) 115 116 def onAdditionsStateChange(self): 117 print "%s: onAdditionsStateChange" %(self.mach.name) 118 119 def onDVDDriveChange(self): 120 print "%s: onDVDDriveChange" %(self.mach.name) 121 122 def onFloppyDriveChange(self): 123 print "%s: onFloppyDriveChange" %(self.mach.name) 124 125 def onNetworkAdapterChange(self, adapter): 126 print "%s: onNetworkAdapterChange" %(self.mach.name) 127 128 def onSerialPortChange(self, port): 129 print "%s: onSerialPortChange" %(self.mach.name) 130 131 def onParallelPortChange(self, port): 132 print "%s: onParallelPortChange" %(self.mach.name) 133 134 def onStorageControllerChange(self): 135 print "%s: onStorageControllerChange" %(self.mach.name) 136 137 def onVRDPServerChange(self): 138 print "%s: onVRDPServerChange" %(self.mach.name) 139 140 def onUSBControllerChange(self): 141 print "%s: onUSBControllerChange" %(self.mach.name) 142 143 def onUSBDeviceStateChange(self, device, attached, error): 144 print "%s: onUSBDeviceStateChange" %(self.mach.name) 145 146 def onSharedFolderChange(self, scope): 147 print "%s: onSharedFolderChange" %(self.mach.name) 148 149 def onRuntimeError(self, fatal, id, message): 150 print "%s: onRuntimeError fatal=%d message=%s" %(self.mach.name, fatal, message) 151 152 def onCanShowWindow(self): 153 print "%s: onCanShowWindow" %(self.mach.name) 154 return true 155 156 def onShowWindow(self, winId): 157 print "%s: onShowWindow: %d" %(self.mach.name, winId) 98 158 99 159 g_hasreadline = 1 … … 242 302 exec cmds 243 303 304 def monitorGuest(ctx, machine, console, dur): 305 import time 306 cb = ctx['global'].createCallback('IConsoleCallback', GuestMonitor, machine) 307 console.registerCallback(cb) 308 if dur == -1: 309 # not infinity, but close enough 310 dur = 100000 311 end = time.clock() + dur 312 while time.clock() < end: 313 ctx['vb'].waitForEvents(100) 314 console.unregisterCallback(cb) 315 244 316 def cmdExistingVm(ctx,mach,cmd,args): 245 317 mgr=ctx['mgr'] … … 267 339 'powerdown': lambda: console.powerDown(), 268 340 'stats': lambda: guestStats(ctx, mach), 269 'guest': lambda: guestExec(ctx, mach, console, args) 341 'guest': lambda: guestExec(ctx, mach, console, args), 342 'monitorGuest': lambda: monitorGuest(ctx, mach, console, args) 270 343 } 271 344 try: … … 467 540 return 0 468 541 542 543 def monitorGuestCmd(ctx, args): 544 if (len(args) < 2): 545 print "usage: monitorGuest name (duration)" 546 return 0 547 mach = argsToMach(ctx,args) 548 if mach == None: 549 return 0 550 dur = 5 551 if len(args) > 2: 552 dur = float(args[2]) 553 cmdExistingVm(ctx, mach, 'monitorGuest', dur) 554 return 0 469 555 470 556 def evalCmd(ctx, args): … … 503 589 'host':['Show host information', hostCmd], 504 590 'guest':['Execute command for guest: guest Win32 console.mouse.putMouseEvent(20, 20, 0, 0)', guestCmd], 591 'monitorGuest':['Monitor what happens with the guest for some time: monitorGuest Win32 10', monitorGuestCmd], 505 592 } 506 593 … … 537 624 try: 538 625 cmd = raw_input("vbox> ") 626 vbox.waitForEvents(0) 539 627 done = runCommand(ctx, cmd) 540 628 if done != 0: break
Note:
See TracChangeset
for help on using the changeset viewer.