Changeset 2731 for package_branches/invirt-web/cherrypy-rebased
- Timestamp:
- Dec 20, 2009, 9:48:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/cherrypy-rebased/code/main.py
r2730 r2731 125 125 def list(self, result=None): 126 126 """Handler for list requests.""" 127 checkpoint.checkpoint('Getting list dict')128 127 d = getListDict(cherrypy.request.login, cherrypy.request.state) 129 128 if result is not None: 130 129 d['result'] = result 131 checkpoint.checkpoint('Got list dict')132 130 return d 133 131 index=list … … 286 284 machine_id=machine_id).machine 287 285 d = infoDict(cherrypy.request.login, cherrypy.request.state, machine) 288 checkpoint.checkpoint('Got infodict')289 286 return d 290 287 index = info … … 394 391 machine = MachineView() 395 392 396 class Checkpoint:397 def __init__(self):398 self.start_time = time.time()399 self.checkpoints = []400 401 def checkpoint(self, s):402 self.checkpoints.append((s, time.time()))403 404 def __str__(self):405 return ('Timing info:\n%s\n' %406 '\n'.join(['%s: %s' % (d, t - self.start_time) for407 (d, t) in self.checkpoints]))408 409 checkpoint = Checkpoint()410 393 411 394 class Defaults: … … 441 424 def getListDict(username, state): 442 425 """Gets the list of local variables used by list.tmpl.""" 443 checkpoint.checkpoint('Starting')444 426 machines = state.machines 445 checkpoint.checkpoint('Got my machines')446 427 on = {} 447 428 has_vnc = {} 448 429 installing = {} 449 430 xmlist = state.xmlist 450 checkpoint.checkpoint('Got uptimes')451 431 for m in machines: 452 432 if m not in xmlist: … … 464 444 max_memory = validation.maxMemory(username, state) 465 445 max_disk = validation.maxDisk(username) 466 checkpoint.checkpoint('Got max mem/disk')467 446 defaults = Defaults(max_memory=max_memory, 468 447 max_disk=max_disk, 469 448 owner=username) 470 checkpoint.checkpoint('Got defaults')471 449 def sortkey(machine): 472 450 return (machine.owner != username, machine.owner, machine.name) … … 598 576 """Get the variables used by info.tmpl.""" 599 577 status = controls.statusInfo(machine) 600 checkpoint.checkpoint('Getting status info')601 578 has_vnc = hasVnc(status) 602 579 if status is None: … … 612 589 cpu_time_float = float(main_status.get('cpu_time', 0)) 613 590 cputime = datetime.timedelta(seconds=int(cpu_time_float)) 614 checkpoint.checkpoint('Status')615 591 display_fields = [('name', 'Name'), 616 592 ('description', 'Description'), … … 658 634 #fields.append((disp, None)) 659 635 660 checkpoint.checkpoint('Got fields')661 662 663 636 max_mem = validation.maxMemory(machine.owner, state, machine, False) 664 checkpoint.checkpoint('Got mem')665 637 max_disk = validation.maxDisk(machine.owner, machine) 666 638 defaults = Defaults() … … 670 642 defaults.type = machine.type.type_id 671 643 defaults.disk = "%0.2f" % (machine.disks[0].size/1024.) 672 checkpoint.checkpoint('Got defaults')673 644 d = dict(user=username, 674 645 on=status is not None,
Note: See TracChangeset
for help on using the changeset viewer.