- Timestamp:
- Apr 26, 2010 3:27:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r28751 r28756 153 153 'magenta':'\033[35m' 154 154 } 155 def colored(str ,color):155 def colored(string,color): 156 156 if not g_hascolors: 157 return str 157 return string 158 158 global term_colors 159 159 col = term_colors.get(color,None) 160 160 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 164 164 165 165 if g_hasreadline: … … 268 268 269 269 def colVm(ctx,vm): 270 return colored( str(vm), 'blue')270 return colored(vm, 'blue') 271 271 272 272 def createVm(ctx,name,kind,base): … … 1335 1335 def connectCmd(ctx, args): 1336 1336 if (len(args) > 4): 1337 print "usage: connect [url] [username] [passwd]"1337 print "usage: connect url <username> <passwd>" 1338 1338 return 0 1339 1339 … … 1357 1357 passwd = "" 1358 1358 1359 ctx['wsinfo'] = [url, user, passwd] 1359 1360 vbox = ctx['global'].platform.connect(url, user, passwd) 1360 1361 ctx['vb'] = vbox … … 1379 1380 1380 1381 ctx['vb'] = None 1382 return 0 1383 1384 def 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) 1381 1397 return 0 1382 1398 … … 2155 2171 print "Unknown command: '%s', type 'help' for list of known commands" %(c) 2156 2172 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 2157 2177 return ci[1](ctx, args) 2158 2178 … … 2216 2236 def interpret(ctx): 2217 2237 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] 2219 2239 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", "", ""] 2220 2242 2221 2243 vbox = ctx['vb']
Note:
See TracChangeset
for help on using the changeset viewer.