Changeset 157 for trunk/web/templates/main.py
- Timestamp:
- Oct 9, 2007, 5:30:50 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/templates/main.py
r154 r157 48 48 def __get_uptimes(self): 49 49 if not hasattr(self, '_uptimes'): 50 self._uptimes = getUptimes( self.machines)50 self._uptimes = getUptimes(Machine.select()) 51 51 return self._uptimes 52 52 uptimes = property(__get_uptimes) … … 232 232 return stack[-1] 233 233 234 def getUptimes(machines ):234 def getUptimes(machines=None): 235 235 """Return a dictionary mapping machine names to uptime strings""" 236 236 value_string = remctl('web', 'listvms') … … 407 407 machines=machines, 408 408 has_vnc=has_vnc, 409 uptimes= uptimes,409 uptimes=g.uptimes, 410 410 cdroms=CDROM.select()) 411 411 return Template(file='list.tmpl', searchList=[d, global_dict]) … … 531 531 def command(user, fields): 532 532 """Handler for running commands like boot and delete on a VM.""" 533 print time.time()-start_time533 print >> sys.stderr, time.time()-start_time 534 534 machine = testMachineId(user, fields.getfirst('machine_id')) 535 535 action = fields.getfirst('action') 536 536 cdrom = fields.getfirst('cdrom') 537 print time.time()-start_time537 print >> sys.stderr, time.time()-start_time 538 538 if cdrom is not None and not CDROM.get(cdrom): 539 539 raise CodeError("Invalid cdrom type '%s'" % cdrom) … … 556 556 elif action == 'Delete VM': 557 557 deleteVM(machine) 558 print time.time()-start_time558 print >> sys.stderr, time.time()-start_time 559 559 560 560 d = dict(user=user, … … 723 723 connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen') 724 724 operation = os.environ.get('PATH_INFO', '') 725 #print 'Content-Type: text/plain\n'726 #print operation725 # print 'Content-Type: text/plain\n' 726 # print operation 727 727 if not operation: 728 728 print "Status: 301 Moved Permanently" … … 734 734 if not operation: 735 735 operation = 'list' 736 736 737 737 def badOperation(u, e): 738 738 raise CodeError("Unknown operation") … … 747 747 e = sys.stderr.read() 748 748 if e: 749 output = output.replace('<body>', '<body><pre>'+e+'</pre>') 749 output = str(output) 750 output = output.replace('<body>', '<body><p>STDERR:</p><pre>'+e+'</pre>') 750 751 print output 751 752 except CodeError, err: … … 753 754 sys.stderr.seek(0) 754 755 e = sys.stderr.read() 756 sys.stderr=sys.stdout 755 757 print error(operation, u, fields, err, e) 756 758 except InvalidInput, err: … … 758 760 sys.stderr.seek(0) 759 761 e = sys.stderr.read() 762 sys.stderr=sys.stdout 760 763 print invalidInput(operation, u, fields, err, e) 761 764 except: … … 765 768 print e 766 769 print '----' 770 sys.stderr = sys.stdout 767 771 raise
Note: See TracChangeset
for help on using the changeset viewer.