Ignore:
Timestamp:
06/11/13 09:33:58 (11 years ago)
Author:
jripsl
Message:

Improve "config-card" file handling.
Use explicite function for "repo_io" module initialization

File:
1 edited

Legend:

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

    r866 r871  
    1414import sys 
    1515import sqlite3 
     16 
     17import types 
    1618 
    1719_conn=None 
     
    3941 
    4042def create_tables(): 
     43 
    4144        _conn.execute("create table simulation (id INTEGER PRIMARY KEY, name TEXT)") 
     45        _conn.execute("create unique index idx_simulation on simulation (name)") 
     46 
    4247        _conn.execute("create table message (id INTEGER PRIMARY KEY, simulation_id TEXT)") # TODO: check how to use INT datatype for simulation_id column 
     48 
     49def populate_tables_with_sample(): 
     50 
     51        rows = [('SIMU-001',), 
     52                        ('SIMU-002',), 
     53                        ('SIMU-003',),] 
     54        _conn.executemany('INSERT INTO simulation (name) VALUES (?)', rows) 
     55 
     56def retrieve_simulations(): 
     57        li=[] 
     58        c=_conn.cursor() 
     59 
     60        c.execute("select name,id from simulation") 
     61 
     62        rs=c.fetchone() 
     63        while rs is not None: 
     64                li.append(types.Simulation(name=rs[0],id=rs[1])) 
     65                rs=c.fetchone() 
     66 
     67        return li 
    4368 
    4469def retrieve_simulation(name): 
     
    5277                raise Exception() 
    5378 
    54         return smon.types.Simulation(id=rs[1]) 
     79        return types.Simulation(id=rs[1]) 
    5580     
    5681def delete_simulation(simulation): 
     
    7297        rs=c.fetchone() 
    7398        while rs is not None: 
    74                 li.append(smon.types.Message(id=rs[0])) 
     99                li.append(types.Message(id=rs[0])) 
    75100                rs=c.fetchone() 
    76101 
     
    93118                raise Exception() 
    94119 
    95         return smon.types.Message(id=rs[0]) 
     120        return types.Message(id=rs[0]) 
Note: See TracChangeset for help on using the changeset viewer.