Changeset 879 for trunk/Monitoring/smon/local_repo.py
- Timestamp:
- 06/13/13 07:08:13 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Monitoring/smon/local_repo.py
r877 r879 59 59 _conn.execute("create unique index if not exists idx_simulation_1 on simulation (name)") 60 60 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 column61 _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 62 62 63 63 def cleanup(): … … 102 102 103 103 if rs is None: 104 raise Exception( )104 raise Exception("name=%s"%name) 105 105 106 106 return types.Simulation(name=rs[0],id=rs[1],status=rs[2]) … … 126 126 c=_conn.cursor() 127 127 128 _conn.execute("select id from message where simulation_id = ?",(simulation.id,))128 c.execute("select id from message where simulation_id = ?",(simulation.id,)) 129 129 130 130 rs=c.fetchone() … … 142 142 def create_message(message,simulation): 143 143 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)) 145 145 146 146 _conn.commit() … … 149 149 c=_conn.cursor() 150 150 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,)) 152 155 153 156 rs=c.fetchone() 154 157 155 158 if rs is None: 159 160 # debug 161 #print "simulation not found (%d)"%simulation.id 162 156 163 raise types.MessageNotFoundException() 157 164 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.