Changeset 30492 in vbox for trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
- Timestamp:
- Jun 29, 2010 11:25:54 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r30455 r30492 432 432 433 433 def monitorVBox2(ctx, dur): 434 def handleEventImpl(ev): 435 print "got event: %s %s" %(ev, str(ev.type)) 436 if ev.type == ctx['global'].constants.VBoxEventType_OnMachineStateChange: 437 scev = ctx['global'].queryInterface(ev, 'IMachineStateChangeEvent') 438 if scev: 439 print "state event: mach=%s state=%s" %(scev.machineId, scev.state) 440 441 class EventListener: 442 def __init__(self, arg): 443 pass 444 445 def handleEvent(self, ev): 446 handleEventImpl(ev) 447 434 448 vbox = ctx['vb'] 435 listener = vbox.eventSource.createListener() 449 active = True 450 if active: 451 listener = ctx['global'].createListener(EventListener) 452 else: 453 listener = vbox.eventSource.createListener() 436 454 registered = False 437 455 if dur == -1: … … 439 457 dur = 100000 440 458 try: 441 vbox.eventSource.registerListener(listener, [ctx['global'].constants.VBoxEventType_Any], False)459 vbox.eventSource.registerListener(listener, [ctx['global'].constants.VBoxEventType_Any], active) 442 460 registered = True 443 461 end = time.time() + dur 444 462 while time.time() < end: 445 ev = vbox.eventSource.getEvent(listener, 500) 446 if ev: 447 print "got event: %s %s" %(ev, str(ev.type)) 448 if ev.type == ctx['global'].constants.VBoxEventType_OnMachineStateChange: 449 scev = ctx['global'].queryInterface(ev, 'IMachineStateChangeEvent') 450 if scev: 451 print "state event: mach=%s state=%s" %(scev.machineId, scev.state) 452 # otherwise waitable events will leak 453 vbox.eventSource.eventProcessed(listener, ev) 463 if active: 464 ctx['global'].waitForEvents(500) 465 else: 466 ev = vbox.eventSource.getEvent(listener, 500) 467 if ev: 468 handleEventImpl(ev) 469 # otherwise waitable events will leak (active listeners ACK automatically) 470 vbox.eventSource.eventProcessed(listener, ev) 454 471 # We need to catch all exceptions here, otherwise listener will never be unregistered 455 except Exception, e: 456 printErr(ctx,e) 457 traceback.print_exc() 472 except: 458 473 pass 459 474 if listener and registered: … … 1013 1028 try: 1014 1029 while True: 1015 data = guest.getProcessOutput(pid, 0, 1000 , 4096)1030 data = guest.getProcessOutput(pid, 0, 10000, 4096) 1016 1031 if data and len(data) > 0: 1017 1032 sys.stdout.write(data) … … 3058 3073 pass 3059 3074 cmds = [] 3060 3075 3061 3076 if g_cmd is not None: 3062 3077 cmds = g_cmd.split(';')
Note:
See TracChangeset
for help on using the changeset viewer.