Ignore:
Timestamp:
06/13/13 07:08:13 (11 years ago)
Author:
jripsl
Message:

Fix heartbeat test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Monitoring/smon/local_repo.py

    r877 r879  
    5959        _conn.execute("create unique index if not exists idx_simulation_1 on simulation (name)") 
    6060 
    61         _conn.execute("create table if not exists message (id INTEGER PRIMARY KEY, simulation_id TEXT, body TEXT, crea_date TEXT)") # TODO: check how to use INT datatype for simulation_id column 
     61        _conn.execute("create table if not exists message (id INTEGER PRIMARY KEY, simulation_id TEXT, body TEXT, timestamp TEXT, crea_date TEXT)") # TODO: check how to use INT datatype for simulation_id column 
    6262 
    6363def cleanup(): 
     
    102102 
    103103        if rs is None: 
    104                 raise Exception() 
     104                raise Exception("name=%s"%name) 
    105105 
    106106        return types.Simulation(name=rs[0],id=rs[1],status=rs[2]) 
     
    126126        c=_conn.cursor() 
    127127 
    128         _conn.execute("select id from message where simulation_id = ?",(simulation.id,)) 
     128        c.execute("select id from message where simulation_id = ?",(simulation.id,)) 
    129129 
    130130        rs=c.fetchone() 
     
    142142def create_message(message,simulation): 
    143143         
    144         _conn.execute("insert into message (simulation_id,crea_date) values (?,?)",(simulation.id, message.timestamp)) 
     144        _conn.execute("insert into message (simulation_id,timestamp,crea_date) values (?,?,datetime('now', 'localtime'))",(simulation.id, message.timestamp)) 
    145145 
    146146        _conn.commit() 
     
    149149        c=_conn.cursor() 
    150150 
    151         _conn.execute("select id, simulation_id, body, crea_date from message where simulation_id=? order by crea_date desc limit 1",(simulation.id,)) 
     151        # debug 
     152        #print "simulation_id=%d"%simulation.id 
     153 
     154        c.execute("select id, simulation_id, body, timestamp, crea_date from message where simulation_id=? order by crea_date desc limit 1",(simulation.id,)) 
    152155 
    153156        rs=c.fetchone() 
    154157 
    155158        if rs is None: 
     159 
     160                # debug 
     161                #print "simulation not found (%d)"%simulation.id 
     162 
    156163                raise types.MessageNotFoundException() 
    157164 
    158         return types.Message(id=rs[0],simulation_id=rs[1],body=rs[2],timestamp=rs[3]) 
     165        # HACK (we want the Message constructor to support BOTH **kw AND kw) 
     166        di={} 
     167        di["id"]=rs[0] 
     168        di["simulation_id"]=rs[1] 
     169        di["body"]=rs[2] 
     170        di["timestamp"]=id=rs[3] 
     171        di["crea_date"]=rs[4] 
     172 
     173        m=types.Message(di) 
     174 
     175        return m 
     176 
     177 
Note: See TracChangeset for help on using the changeset viewer.