VirtualBox

Changeset 21517 in vbox for trunk/src


Ignore:
Timestamp:
Jul 13, 2009 8:10:29 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49969
Message:

Python shell: allow executing existing commands from extensions

File:
1 edited

Legend:

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

    r21419 r21517  
    3030import traceback
    3131import shlex
     32import time
    3233
    3334# Simple implementation of IConsoleCallback, one can use it as skeleton
     
    276277
    277278def monitorGuest(ctx, machine, console, dur):
    278     import time
    279279    cb = ctx['global'].createCallback('IConsoleCallback', GuestMonitor, machine)
    280280    console.registerCallback(cb)
     
    293293
    294294def monitorVbox(ctx, dur):
    295     import time
    296295    vbox = ctx['vb']
    297296    cb = ctx['global'].createCallback('IVirtualBoxCallback', VBoxMonitor, vbox)
     
    413412
    414413def infoCmd(ctx,args):
    415     import time
    416414    if (len(args) < 2):
    417415        print "usage: info [vmname|uuid]"
     
    736734    return 0
    737735
     736def sleepCmd(ctx, args):
     737    if (len(args) != 2):
     738        print "usage: sleep <secs>"
     739        return 0
     740
     741    time.sleep(float(args[1]))
    738742
    739743aliases = {'s':'start',
     
    770774            'reloadExt':['Reload custom extensions: reloadExt', reloadExtCmd, 0],
    771775            'runScript':['Run VBox script: runScript script.vbox', runScriptCmd, 0],
     776            'sleep':['Sleep for specified number of seconds: sleep <secs>', sleepCmd, 0],
    772777            }
    773778
    774 def runCommand(ctx, cmd):
    775     if len(cmd) == 0: return 0
    776     args = split_no_quotes(cmd)
    777     if len(args) == 0: return 0
     779def runCommandArgs(ctx, args):
    778780    c = args[0]
    779781    if aliases.get(c, None) != None:
     
    784786        return 0
    785787    return ci[1](ctx, args)
     788
     789
     790def runCommand(ctx, cmd):
     791    if len(cmd) == 0: return 0
     792    args = split_no_quotes(cmd)
     793    if len(args) == 0: return 0
     794    return runCommandArgs(ctx, args)
    786795
    787796#
     
    853862        pass
    854863
     864def runCommandCb(ctx, cmd, args):
     865    args.insert(0, cmd)
     866    return runCommandArgs(ctx, args)
     867
    855868def main(argv):
    856869    style = None
     
    880893           'ifaces':g_virtualBoxManager.constants,
    881894           'remote':g_virtualBoxManager.remote,
    882            'type':g_virtualBoxManager.type
     895           'type':g_virtualBoxManager.type,
     896           'run':runCommandCb
    883897           }
    884898    interpret(ctx)
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