Changeset 2653
- Timestamp:
- Dec 20, 2009, 7:35:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/cherrypy/code/main.py
r2652 r2653 130 130 def list(self, result=None): 131 131 """Handler for list requests.""" 132 checkpoint.checkpoint('Getting list dict')133 132 d = getListDict(cherrypy.request.login, cherrypy.request.state) 134 133 if result is not None: 135 134 d['result'] = result 136 checkpoint.checkpoint('Got list dict')137 135 return d 138 136 index=list … … 291 289 machine_id=machine_id).machine 292 290 d = infoDict(cherrypy.request.login, cherrypy.request.state, machine) 293 checkpoint.checkpoint('Got infodict')294 291 return d 295 292 index = info … … 448 445 machine = MachineView() 449 446 450 class Checkpoint:451 def __init__(self):452 self.start_time = time.time()453 self.checkpoints = []454 455 def checkpoint(self, s):456 self.checkpoints.append((s, time.time()))457 458 def __str__(self):459 return ('Timing info:\n%s\n' %460 '\n'.join(['%s: %s' % (d, t - self.start_time) for461 (d, t) in self.checkpoints]))462 463 checkpoint = Checkpoint()464 447 465 448 class Defaults: … … 495 478 def getListDict(username, state): 496 479 """Gets the list of local variables used by list.tmpl.""" 497 checkpoint.checkpoint('Starting')498 480 machines = state.machines 499 checkpoint.checkpoint('Got my machines')500 481 on = {} 501 482 has_vnc = {} 502 483 installing = {} 503 484 xmlist = state.xmlist 504 checkpoint.checkpoint('Got uptimes')505 485 for m in machines: 506 486 if m not in xmlist: … … 518 498 max_memory = validation.maxMemory(username, state) 519 499 max_disk = validation.maxDisk(username) 520 checkpoint.checkpoint('Got max mem/disk')521 500 defaults = Defaults(max_memory=max_memory, 522 501 max_disk=max_disk, 523 502 owner=username) 524 checkpoint.checkpoint('Got defaults')525 503 def sortkey(machine): 526 504 return (machine.owner != username, machine.owner, machine.name) … … 652 630 """Get the variables used by info.tmpl.""" 653 631 status = controls.statusInfo(machine) 654 checkpoint.checkpoint('Getting status info')655 632 has_vnc = hasVnc(status) 656 633 if status is None: … … 666 643 cpu_time_float = float(main_status.get('cpu_time', 0)) 667 644 cputime = datetime.timedelta(seconds=int(cpu_time_float)) 668 checkpoint.checkpoint('Status')669 645 display_fields = [('name', 'Name'), 670 646 ('description', 'Description'), … … 712 688 #fields.append((disp, None)) 713 689 714 checkpoint.checkpoint('Got fields')715 716 717 690 max_mem = validation.maxMemory(machine.owner, state, machine, False) 718 checkpoint.checkpoint('Got mem')719 691 max_disk = validation.maxDisk(machine.owner, machine) 720 692 defaults = Defaults() … … 724 696 defaults.type = machine.type.type_id 725 697 defaults.disk = "%0.2f" % (machine.disks[0].size/1024.) 726 checkpoint.checkpoint('Got defaults')727 698 d = dict(user=username, 728 699 on=status is not None,
Note: See TracChangeset
for help on using the changeset viewer.