Changeset 28889 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 29, 2010 12:21:39 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60829
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r28817 r28889 221 221 delims = readline.get_completer_delims() 222 222 readline.set_completer_delims(re.sub("[\\.]", "", delims)) # remove some of the delimiters 223 readline.parse_and_bind("set editing-mode emacs") 223 readline.parse_and_bind("set editing-mode emacs") 224 224 # OSX need it 225 225 if platform.system() == 'Darwin': … … 265 265 def colVm(ctx,vm): 266 266 return colored(vm, 'blue') 267 268 def colPath(ctx,vm): 269 return colored(vm, 'green') 270 267 271 268 272 def createVm(ctx,name,kind,base): … … 520 524 521 525 def cmdExistingVm(ctx,mach,cmd,args): 522 mgr=ctx['mgr']523 vb=ctx['vb']524 session = mgr.getSessionObject(vb)525 uuid = mach.id526 526 try: 527 progress = vb.openExistingSession(session, uuid)527 session = ctx['global'].openMachineSession(mach.id) 528 528 except Exception,e: 529 529 printErr(ctx, "Session to '%s' not open: %s" %(mach.name,str(e))) … … 531 531 traceback.print_exc() 532 532 return 533 if s tr(session.state) != str(ctx['ifaces'].SessionState_Open):533 if session.state != ctx['ifaces'].SessionState_Open: 534 534 print "Session to '%s' in wrong state: %s" %(mach.name, session.state) 535 session.close() 535 536 return 536 537 # this could be an example how to handle local only (i.e. unavailable … … 538 539 if ctx['remote'] and cmd == 'some_local_only_command': 539 540 print 'Trying to use local only functionality, ignored' 541 session.close() 540 542 return 541 543 console=session.console … … 571 573 mach = session.machine 572 574 try: 573 575 cmd(ctx, mach, args) 574 576 except Exception, e: 577 save = False 575 578 printErr(ctx,e) 576 579 if g_verbose: … … 578 581 if save: 579 582 mach.saveSettings() 580 session.close() 583 ctx['global'].closeMachineSession(session) 584 585 586 def cmdAnyVm(ctx,mach,cmd, args=[],save=False): 587 session = ctx['global'].openMachineSession(mach.id) 588 mach = session.machine 589 try: 590 cmd(ctx, mach, session.console, args) 591 except Exception, e: 592 save = False; 593 printErr(ctx,e) 594 if g_verbose: 595 traceback.print_exc() 596 if save: 597 mach.saveSettings() 598 ctx['global'].closeMachineSession(session) 581 599 582 600 def machById(ctx,id): … … 1114 1132 def hostCmd(ctx, args): 1115 1133 vb = ctx['vb'] 1116 print "VirtualBox version %s" %(vb.version) 1134 print "VirtualBox version %s" %(colored(vb.version, 'blue')) 1135 props = vb.systemProperties 1136 print "Machines: %s" %(colPath(ctx,props.defaultMachineFolder)) 1137 print "HDDs: %s" %(colPath(ctx,props.defaultHardDiskFolder)) 1138 1117 1139 #print "Global shared folders:" 1118 1140 #for ud in ctx['global'].getArray(vb, 'sharedFolders'): … … 2097 2119 if not found: 2098 2120 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx,mach,console,args: console.removeSharedFolder(name)]) 2121 return 0 2122 2123 2124 def snapshotCmd(ctx,args): 2125 if (len(args) < 2 or args[1] == 'help'): 2126 print "Take snapshot: snapshot vm take name <description>" 2127 print "Restore snapshot: snapshot vm restore name" 2128 print "Merge snapshot: snapshot vm merge name" 2129 return 0 2130 2131 mach = argsToMach(ctx,args) 2132 if mach is None: 2133 return 0 2134 cmd = args[2] 2135 if cmd == 'take': 2136 if (len(args) < 4): 2137 print "usage: snapshot vm take name <description>" 2138 return 0 2139 name = args[3] 2140 if (len(args) > 4): 2141 desc = args[4] 2142 else: 2143 desc = "" 2144 cmdAnyVm(ctx, mach, lambda ctx,mach,console,args: progressBar(ctx, console.takeSnapshot(name,desc))) 2145 2146 if cmd == 'restore': 2147 if (len(args) < 4): 2148 print "usage: snapshot vm restore name" 2149 return 0 2150 name = args[3] 2151 snap = mach.findSnapshot(name) 2152 cmdAnyVm(ctx, mach, lambda ctx,mach,console,args: progressBar(ctx, console.restoreSnapshot(snap))) 2153 return 0 2154 2155 if cmd == 'restorecurrent': 2156 if (len(args) < 4): 2157 print "usage: snapshot vm restorecurrent" 2158 return 0 2159 snap = mach.currentSnapshot() 2160 cmdAnyVm(ctx, mach, lambda ctx,mach,console,args: progressBar(ctx, console.restoreSnapshot(snap))) 2161 return 0 2162 2163 if cmd == 'delete': 2164 if (len(args) < 4): 2165 print "usage: snapshot vm delete name" 2166 return 0 2167 name = args[3] 2168 snap = mach.findSnapshot(name) 2169 cmdAnyVm(ctx, mach, lambda ctx,mach,console,args: progressBar(ctx, console.deleteSnapshot(snap.id))) 2170 return 0 2171 2172 print "Command '%s' is unknown" %(cmd) 2173 2099 2174 return 0 2100 2175 … … 2172 2247 'gui': ['Start GUI frontend', guiCmd, 0], 2173 2248 'colors':['Toggle colors', colorsCmd, 0], 2249 'snapshot':['VM snapshot manipulation, snapshot help for more info', snapshotCmd, 0], 2174 2250 } 2175 2251
Note:
See TracChangeset
for help on using the changeset viewer.