VirtualBox

Changeset 28756 in vbox for trunk


Ignore:
Timestamp:
Apr 26, 2010 3:27:50 PM (15 years ago)
Author:
vboxsync
Message:

vboxshell: more WS stuff

File:
1 edited

Legend:

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

    r28751 r28756  
    153153    'magenta':'\033[35m'
    154154    }
    155 def colored(str,color):
     155def colored(string,color):
    156156    if not g_hascolors:
    157         return str
     157        return string
    158158    global term_colors
    159159    col = term_colors.get(color,None)
    160160    if col:
    161         return col+str+'\033[0m'
    162     else:
    163         return str
     161        return col+str(string)+'\033[0m'
     162    else:
     163        return string
    164164
    165165if g_hasreadline:
     
    268268
    269269def colVm(ctx,vm):
    270     return colored(str(vm), 'blue')
     270    return colored(vm, 'blue')
    271271
    272272def createVm(ctx,name,kind,base):
     
    13351335def connectCmd(ctx, args):
    13361336    if (len(args) > 4):
    1337         print "usage: connect [url] [username] [passwd]"
     1337        print "usage: connect url <username> <passwd>"
    13381338        return 0
    13391339
     
    13571357        passwd = ""
    13581358
     1359    ctx['wsinfo'] = [url, user, passwd]
    13591360    vbox = ctx['global'].platform.connect(url, user, passwd)
    13601361    ctx['vb'] = vbox
     
    13791380
    13801381    ctx['vb'] = None
     1382    return 0
     1383
     1384def reconnectCmd(ctx, args):
     1385    if ctx['wsinfo'] is None:
     1386        print "Never connected..."
     1387        return 0
     1388
     1389    try:
     1390        ctx['global'].platform.disconnect()
     1391    except:
     1392        pass
     1393
     1394    [url,user,passwd] = ctx['wsinfo']
     1395    ctx['vb'] = ctx['global'].platform.connect(url, user, passwd)
     1396    print "Running VirtualBox version %s" %(ctx['vb'].version)
    13811397    return 0
    13821398
     
    21552171        print "Unknown command: '%s', type 'help' for list of known commands" %(c)
    21562172        return 0
     2173    if ctx['remote'] and ctx['vb'] is None:
     2174        if c not in ['connect', 'reconnect', 'help', 'quit']:
     2175            print "First connect to remote server with %s command." %(colored('connect', 'blue'))
     2176            return 0
    21572177    return ci[1](ctx, args)
    21582178
     
    22162236def interpret(ctx):
    22172237    if ctx['remote']:
    2218         commands['connect'] = ["Connect to remote VBox instance", connectCmd, 0]
     2238        commands['connect'] = ["Connect to remote VBox instance: connect http://server:18083 user password", connectCmd, 0]
    22192239        commands['disconnect'] = ["Disconnect from remote VBox instance", disconnectCmd, 0]
     2240        commands['reconnect'] = ["Reconnect to remote VBox instance", reconnectCmd, 0]
     2241        ctx['wsinfo'] = ["http://localhost:18083", "", ""]
    22202242
    22212243    vbox = ctx['vb']
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