Changeset 16366 in vbox for trunk/src/libs/xpcom18a4/python/sample
- Timestamp:
- Jan 29, 2009 1:37:40 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42210
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/python/sample/shellcommon.py
r13205 r16366 18 18 def __init__(self, vb): 19 19 """ Initializes the instance. 20 20 21 21 Pass an instance of IVirtualBox as parameter. 22 22 """ 23 self.collector = vb.performanceCollector 23 self.collector = vb.performanceCollector 24 24 25 25 def setup(self, names, objects, period, nsamples): … … 100 100 in self.namespace that match. 101 101 """ 102 102 103 103 matches = [] 104 104 n = len(text) … … 112 112 try: 113 113 for m in getMachines(self.ctx): 114 # although it has autoconversion, we need to cast 114 # although it has autoconversion, we need to cast 115 115 # explicitly for subscripts to work 116 116 word = str(m.name) … … 132 132 if not g_hasreadline: 133 133 return 134 134 135 135 comps = {} 136 136 for (k,v) in commands.items(): … … 144 144 def split_no_quotes(s): 145 145 return s.split() 146 146 147 147 def startVm(mgr,vb,mach,type,perf): 148 148 session = mgr.getSessionObject(vb) … … 154 154 print "Completed:", completed, "rc:",rc 155 155 if int(rc) == 0: 156 # we ignore exceptions to allow starting VM even if 156 # we ignore exceptions to allow starting VM even if 157 157 # perf collector cannot be started 158 158 try: … … 197 197 if ctx['remote'] and cmd == 'stats2': 198 198 print 'Trying to use local only functionality, ignored' 199 return 199 return 200 200 console=session.console 201 201 ops={'pause' : lambda: console.pause(), … … 236 236 print "Help page:" 237 237 for i in commands: 238 print " ",i,":", commands[i][0] 238 print " ",i,":", commands[i][0] 239 239 else: 240 240 c = commands.get(args[1], None) … … 254 254 print "usage: info [vmname|uuid]" 255 255 return 0 256 mach = argsToMach(ctx,args) 256 mach = argsToMach(ctx,args) 257 257 if mach == None: 258 258 return 0 … … 263 263 print " RAM: %dM" %(mach.memorySize) 264 264 print " VRAM: %dM" %(mach.VRAMSize) 265 print " Monitors: %d" %(mach.MonitorCount)266 265 print " Clipboard mode: %d" %(mach.clipboardMode) 267 266 print " Machine status: " ,mach.sessionState … … 273 272 print " Last changed: ",mach.lastStateChange 274 273 275 return 0 274 return 0 276 275 277 276 def startCmd(ctx, args): 278 mach = argsToMach(ctx,args) 277 mach = argsToMach(ctx,args) 279 278 if mach == None: 280 279 return 0 … … 287 286 288 287 def pauseCmd(ctx, args): 289 mach = argsToMach(ctx,args) 288 mach = argsToMach(ctx,args) 290 289 if mach == None: 291 290 return 0 … … 294 293 295 294 def powerdownCmd(ctx, args): 296 mach = argsToMach(ctx,args) 295 mach = argsToMach(ctx,args) 297 296 if mach == None: 298 297 return 0 … … 301 300 302 301 def resumeCmd(ctx, args): 303 mach = argsToMach(ctx,args) 302 mach = argsToMach(ctx,args) 304 303 if mach == None: 305 304 return 0 … … 308 307 309 308 def statsCmd(ctx, args): 310 mach = argsToMach(ctx,args) 309 mach = argsToMach(ctx,args) 311 310 if mach == None: 312 311 return 0 … … 318 317 print "usage: setvar [vmname|uuid] expr value" 319 318 return 0 320 mach = argsToMach(ctx,args) 319 mach = argsToMach(ctx,args) 321 320 if mach == None: 322 321 return 0 … … 341 340 342 341 def aliasesCmd(ctx, args): 343 for (k,v) in aliases.items(): 342 for (k,v) in aliases.items(): 344 343 print "'%s' is an alias for '%s'" %(k,v) 345 344 return 0 … … 356 355 for i in range(0,cnt): 357 356 print "Processor #%d speed: %dMHz" %(i,host.getProcessorSpeed(i)) 358 357 359 358 for metric in ctx['perf'].query(["*"], [host]): 360 359 print metric['name'], metric['values_as_string'] … … 373 372 return 0 374 373 375 aliases = {'s':'start', 374 aliases = {'s':'start', 376 375 'i':'info', 377 376 'l':'list', … … 397 396 398 397 def runCommand(ctx, cmd): 399 if len(cmd) == 0: return 0 398 if len(cmd) == 0: return 0 400 399 args = split_no_quotes(cmd) 401 if len(args) == 0: return 0 400 if len(args) == 0: return 0 402 401 c = args[0] 403 402 if aliases.get(c, None) != None: … … 430 429 done = runCommand(ctx, cmd) 431 430 if done != 0: break 432 except KeyboardInterrupt: 431 except KeyboardInterrupt: 433 432 print '====== You can type quit or q to leave' 434 433 break
Note:
See TracChangeset
for help on using the changeset viewer.