VirtualBox

Changeset 18123 in vbox


Ignore:
Timestamp:
Mar 20, 2009 4:39:48 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
44799
Message:

vboxshell: implement guest command, to directly talk with concrete guest

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/sample/shellcommon.py

    r17908 r18123  
    204204        print metric['name'], metric['values_as_string']
    205205
    206 def cmdExistingVm(ctx,mach,cmd):
     206def guestExec(ctx, machine, console, cmds):
     207    exec cmds
     208
     209def cmdExistingVm(ctx,mach,cmd,args):
    207210    mgr=ctx['mgr']
    208211    vb=ctx['vb']
     
    224227        print 'Trying to use local only functionality, ignored'
    225228        return
    226     console=session.console
     229    console=session.console   
    227230    ops={'pause' :     lambda: console.pause(),
    228231         'resume':     lambda: console.resume(),
    229232         'powerdown':  lambda: console.powerDown(),
    230233         'stats':      lambda: guestStats(ctx, mach),
     234         'guest':      lambda: guestExec(ctx, mach, console, args)
    231235         }
    232     ops[cmd]()
     236    try:
     237        ops[cmd]()
     238    except Exception, e:
     239        print 'failed: ',e
     240        if g_verbose:
     241            traceback.print_exc()
     242
    233243    session.close()
    234244
     
    340350    if mach == None:
    341351        return 0
    342     cmdExistingVm(ctx, mach, 'pause')
     352    cmdExistingVm(ctx, mach, 'pause', '')
    343353    return 0
    344354
     
    347357    if mach == None:
    348358        return 0
    349     cmdExistingVm(ctx, mach, 'powerdown')
     359    cmdExistingVm(ctx, mach, 'powerdown', '')
    350360    return 0
    351361
     
    354364    if mach == None:
    355365        return 0
    356     cmdExistingVm(ctx, mach, 'resume')
     366    cmdExistingVm(ctx, mach, 'resume', '')
    357367    return 0
    358368
     
    361371    if mach == None:
    362372        return 0
    363     cmdExistingVm(ctx, mach, 'stats')
     373    cmdExistingVm(ctx, mach, 'stats', '')
     374    return 0
     375
     376def guestCmd(ctx, args):
     377    if (len(args) < 3):
     378        print "usage: guest name commands"
     379        return 0
     380    mach = argsToMach(ctx,args)
     381    if mach == None:
     382        return 0
     383    cmdExistingVm(ctx, mach, 'guest', ' '.join(args[2:]))
    364384    return 0
    365385
     
    446466            'eval':['Evaluate arbitrary Python construction: eval for m in getMachines(ctx): print m.name,"has",m.memorySize,"M"', evalCmd],
    447467            'quit':['Exits', quitCmd],
    448             'host':['Show host information', hostCmd]}
     468            'host':['Show host information', hostCmd],
     469            'guest':['Execute command for guest: guest Win32 console.mouse.putMouseEvent(20, 20, 0, 0)', guestCmd],
     470            }
    449471
    450472def runCommand(ctx, cmd):
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