Changeset 21924 in vbox for trunk/src/VBox/Frontends/VBoxShell
- Timestamp:
- Aug 1, 2009 3:55:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r21907 r21924 206 206 return shlex.split(s) 207 207 208 def progressBar(ctx,p,wait=1000): 209 try: 210 while not p.completed: 211 print "%d %%\r" %(p.percent), 212 sys.stdout.flush() 213 p.waitForCompletion(wait) 214 except KeyboardInterrupt: 215 print "Interrupted." 216 208 217 def createVm(ctx,name,kind,base): 209 218 mgr = ctx['mgr'] … … 223 232 session = ctx['global'].openMachineSession(id) 224 233 try: 225 mach = session. Machine234 mach = session.machine 226 235 for d in ctx['global'].getArray(mach, 'hardDiskAttachments'): 227 236 mach.detachHardDisk(d.controller, d.port, d.device) 228 237 except: 229 238 traceback.print_exc() 239 mach.saveSettings() 230 240 ctx['global'].closeMachineSession(session) 231 241 mach = vb.unregisterMachine(id) … … 242 252 uuid = mach.id 243 253 progress = vb.openRemoteSession(session, uuid, type, "") 244 progress .waitForCompletion(-1)254 progressBar(ctx, progress, 100) 245 255 completed = progress.completed 246 256 rc = int(progress.resultCode) … … 348 358 'guest': lambda: guestExec(ctx, mach, console, args), 349 359 'monitorGuest': lambda: monitorGuest(ctx, mach, console, args), 350 'save': lambda: console.saveState().waitForCompletion(-1)360 'save': lambda: progressBar(ctx,console.saveState()) 351 361 } 352 362 try: … … 383 393 return m 384 394 395 def helpSingleCmd(cmd,h,sp): 396 if sp != 0: 397 spec = " [ext from "+sp+"]" 398 else: 399 spec = "" 400 print " %s: %s%s" %(cmd,h,spec) 401 385 402 def helpCmd(ctx, args): 386 403 if len(args) == 1: … … 389 406 names.sort() 390 407 for i in names: 391 print " ",i,":", commands[i][0] 392 else: 393 c = commands.get(args[1], None) 408 helpSingleCmd(i, commands[i][0], commands[i][2]) 409 else: 410 cmd = args[1] 411 c = commands.get(cmd) 394 412 if c == None: 395 print "Command '%s' not known" %( args[1])413 print "Command '%s' not known" %(cmd) 396 414 else: 397 print " ",args[1],":", c[0]415 helpSingleCmd(cmd, c[0], c[2]) 398 416 return 0 399 417 … … 905 923 desc.addDescription(ctx['global'].constants.VirtualSystemDescriptionType_License, license, "") 906 924 p = app.write(format, path) 907 try: 908 while not p.completed: 909 print "%d %%\r" %(p.percent), 910 sys.stdout.flush() 911 p.waitForCompletion(1000) 912 except KeyboardInterrupt: 913 print "Interrupted." 925 progressBar(ctx, p) 914 926 print "Exported to %s in format %s" %(path, format) 915 927 return 0 … … 982 994 # } 983 995 # and issue reloadExt shell command. 984 # This file also will be read automatically on startup .996 # This file also will be read automatically on startup or 'reloadExt'. 985 997 # 986 def checkUserExtensions(ctx, cmds, folder): 987 name = os.path.join(str(folder), "shellext.py") 988 if not os.path.isfile(name): 998 # Also one can put shell extensions into ~/.VirtualBox/shexts and 999 # they will also be picked up, so this way one can exchange 1000 # shell extensions easily. 1001 def addExtsFromFile(ctx, cmds, file): 1002 if not os.path.isfile(file): 989 1003 return 990 1004 d = {} 991 1005 try: 992 execfile( name, d, d)1006 execfile(file, d, d) 993 1007 for (k,v) in d['commands'].items(): 994 1008 if g_verbose: 995 1009 print "customize: adding \"%s\" - %s" %(k, v[0]) 996 cmds[k] = [v[0], v[1], 1]1010 cmds[k] = [v[0], v[1], file] 997 1011 except: 998 print "Error loading user extensions :"1012 print "Error loading user extensions from %s" %(file) 999 1013 traceback.print_exc() 1014 1015 1016 def checkUserExtensions(ctx, cmds, folder): 1017 name = os.path.join(folder, "shellext.py") 1018 addExtsFromFile(ctx, cmds, name) 1019 # also check 'exts' directory for all files 1020 shextdir = os.path.join(folder, "shexts") 1021 if not os.path.isdir(shextdir): 1022 return 1023 exts = os.listdir(shextdir) 1024 for e in exts: 1025 addExtsFromFile(ctx, cmds, os.path.join(shextdir,e)) 1000 1026 1001 1027 def interpret(ctx): … … 1082 1108 'run': lambda cmd,args: runCommandCb(ctx, cmd, args), 1083 1109 'machById': lambda id: machById(ctx,id), 1110 'progressBar': lambda p: progressBar(ctx,p), 1084 1111 '_machlist':None 1085 1112 }
Note:
See TracChangeset
for help on using the changeset viewer.