Ignore:
Timestamp:
Oct 9, 2007, 5:30:50 PM (17 years ago)
Author:
ecprice
Message:

Bugfixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/templates/main.py

    r154 r157  
    4848    def __get_uptimes(self):
    4949        if not hasattr(self, '_uptimes'):
    50             self._uptimes = getUptimes(self.machines)
     50            self._uptimes = getUptimes(Machine.select())
    5151        return self._uptimes
    5252    uptimes = property(__get_uptimes)
     
    232232    return stack[-1]
    233233
    234 def getUptimes(machines):
     234def getUptimes(machines=None):
    235235    """Return a dictionary mapping machine names to uptime strings"""
    236236    value_string = remctl('web', 'listvms')
     
    407407             machines=machines,
    408408             has_vnc=has_vnc,
    409              uptimes=uptimes,
     409             uptimes=g.uptimes,
    410410             cdroms=CDROM.select())
    411411    return Template(file='list.tmpl', searchList=[d, global_dict])
     
    531531def command(user, fields):
    532532    """Handler for running commands like boot and delete on a VM."""
    533     print time.time()-start_time
     533    print >> sys.stderr, time.time()-start_time
    534534    machine = testMachineId(user, fields.getfirst('machine_id'))
    535535    action = fields.getfirst('action')
    536536    cdrom = fields.getfirst('cdrom')
    537     print time.time()-start_time
     537    print >> sys.stderr, time.time()-start_time
    538538    if cdrom is not None and not CDROM.get(cdrom):
    539539        raise CodeError("Invalid cdrom type '%s'" % cdrom)   
     
    556556    elif action == 'Delete VM':
    557557        deleteVM(machine)
    558     print time.time()-start_time
     558    print >> sys.stderr, time.time()-start_time
    559559
    560560    d = dict(user=user,
     
    723723    connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen')
    724724    operation = os.environ.get('PATH_INFO', '')
    725     #print 'Content-Type: text/plain\n'
    726     #print operation
     725#    print 'Content-Type: text/plain\n'
     726#    print operation
    727727    if not operation:
    728728        print "Status: 301 Moved Permanently"
     
    734734    if not operation:
    735735        operation = 'list'
    736    
     736
    737737    def badOperation(u, e):
    738738        raise CodeError("Unknown operation")
     
    747747        e = sys.stderr.read()
    748748        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>')
    750751        print output
    751752    except CodeError, err:
     
    753754        sys.stderr.seek(0)
    754755        e = sys.stderr.read()
     756        sys.stderr=sys.stdout
    755757        print error(operation, u, fields, err, e)
    756758    except InvalidInput, err:
     
    758760        sys.stderr.seek(0)
    759761        e = sys.stderr.read()
     762        sys.stderr=sys.stdout
    760763        print invalidInput(operation, u, fields, err, e)
    761764    except:
     
    765768        print e
    766769        print '----'
     770        sys.stderr = sys.stdout
    767771        raise
Note: See TracChangeset for help on using the changeset viewer.