CMS 3D CMS Logo

Public Member Functions | Public Attributes

results_db::ResultsDB Class Reference

List of all members.

Public Member Functions

def __init__
def addResultLog
def checkResult
def create
def deleteResultSteps
def deleteRun
def drop
def getDate
def getNewResId
def getNewRunId
def read
def readResults
def readRun
def readSelection
def writeResult
def writeStepResult

Public Attributes

 conn

Detailed Description

Definition at line 29 of file results_db.py.


Constructor & Destructor Documentation

def results_db::ResultsDB::__init__ (   self,
  connect 
)

Definition at line 30 of file results_db.py.

00031                                :
00032         self.conn = connect


Member Function Documentation

def results_db::ResultsDB::addResultLog (   self,
  runID,
  logStr 
)

Definition at line 195 of file results_db.py.

00196                                          :
00197         curs = self.conn.cursor()
00198         sqlstr = "UPDATE RUN_HEADER SET LOG = :lstr WHERE RID = :rid"
00199         curs.prepare(sqlstr)
00200         curs.execute(sqlstr, lstr = logStr, rid=runID)
00201         self.conn.commit()

def results_db::ResultsDB::checkResult (   self,
  runID 
)

Definition at line 202 of file results_db.py.

00203                                   :
00204         curs = self.conn.cursor()
00205         sqlstr = "SELECT ID FROM RUN_RESULT WHERE RID=:rid"
00206         curs.prepare(sqlstr)
00207         curs.execute(sqlstr, rid=runID)
00208         for row in curs:
00209             innercur = self.conn.cursor()
00210             isqlstr = "SELECT STATUS FROM RUN_STEP_RESULT WHERE ID= :ids"
00211             innercur.prepare(isqlstr)
00212             innercur.execute(isqlstr, ids=row[0])
00213             for irow in innercur:
00214                 if irow[0] != 0:
00215                     return False
00216         return True

def results_db::ResultsDB::create (   self)

Definition at line 33 of file results_db.py.

00034                       :
00035         curs = self.conn.cursor()
00036         sqlstr = "CREATE TABLE RUN_HEADER (RID NUMBER, RDATE DATE, LABEL VARCHAR2(20), "
00037         sqlstr += "T_RELEASE VARCHAR2(50), T_ARCH VARCHAR2(30), LOG CLOB "
00038         sqlstr += "CONSTRAINT PK_ID0 PRIMARY KEY(RID))"
00039         curs.prepare(sqlstr)
00040         curs.execute(sqlstr)
00041         sqlstr = "CREATE TABLE RUN_RESULT (ID NUMBER, RID NUMBER, R_RELEASE VARCHAR(50), R_ARCH VARCHAR2(30) "
00042         sqlstr += "CONSTRAINT PK_ID PRIMARY KEY(ID))"
00043         curs.prepare(sqlstr)
00044         curs.execute(sqlstr)
00045         sqlstr = "CREATE TABLE RUN_STEP_RESULT (ID NUMBER, STEP_LABEL VARCHAR(100), STATUS NUMBER)"
00046         curs.prepare(sqlstr)
00047         curs.execute(sqlstr)
00048         sqlstr = "CREATE SEQUENCE RUN_ID_SEQ INCREMENT BY 1 START WITH 1"
00049         curs.prepare(sqlstr)
00050         curs.execute(sqlstr)
00051         sqlstr = "CREATE SEQUENCE RES_ID_SEQ INCREMENT BY 1 START WITH 1"
00052         curs.prepare(sqlstr)
00053         curs.execute(sqlstr)
00054         self.conn.commit()
00055         print 'RESULTS DATABASE CREATED'
        
def results_db::ResultsDB::deleteResultSteps (   self,
  id 
)

Definition at line 159 of file results_db.py.

00160                                      :
00161         curs = self.conn.cursor()
00162         sqlstr = "DELETE FROM RUN_STEP_RESULT WHERE ID=:ids"
00163         curs.prepare(sqlstr)
00164         curs.execute(sqlstr, ids=id)
                
def results_db::ResultsDB::deleteRun (   self,
  rid 
)

Definition at line 144 of file results_db.py.

00145                              :
00146         curs = self.conn.cursor()
00147         sqlstr = "SELECT ID FROM RUN_RESULT WHERE RID = :rids"
00148         curs.prepare(sqlstr)
00149         curs.execute(sqlstr, rids=rid)
00150         for row in curs:
00151             self.deleteResultSteps( row[0] )
00152         sqlstr = "DELETE FROM RUN_RESULT WHERE RID = :rids"
00153         curs.prepare(sqlstr)
00154         curs.execute(sqlstr, rids=rid)
00155         sqlstr = "DELETE FROM RUN_HEADER WHERE RID = :rids"
00156         curs.prepare(sqlstr)
00157         curs.execute(sqlstr, rids=rid)
00158         self.conn.commit()         

def results_db::ResultsDB::drop (   self)

Definition at line 56 of file results_db.py.

00057                     :
00058         curs = self.conn.cursor()
00059         sqlstr = "DROP TABLE RUN_HEADER"
00060         curs.prepare(sqlstr)
00061         curs.execute(sqlstr)
00062         sqlstr = "DROP TABLE RUN_RESULT"
00063         curs.prepare(sqlstr)
00064         curs.execute(sqlstr)
00065         sqlstr = "DROP TABLE RUN_STEP_RESULT"
00066         curs.prepare(sqlstr)
00067         curs.execute(sqlstr)
00068         sqlstr = "DROP SEQUENCE RES_ID_SEQ"
00069         curs.prepare(sqlstr)
00070         curs.execute(sqlstr)
00071         self.conn.commit()
00072         print 'RESULT DATABASE DROPPED'
        
def results_db::ResultsDB::getDate (   self)

Definition at line 233 of file results_db.py.

00234                        :
00235         curs = self.conn.cursor()
00236         sqlstr = "SELECT SYSTIMESTAMP AS \"NOW\" FROM DUAL"
00237         curs.prepare(sqlstr)
00238         curs.execute(sqlstr)
00239         for row in curs:
00240                 return row[0]
00241 
def results_db::ResultsDB::getNewResId (   self)

Definition at line 217 of file results_db.py.

00218                            :
00219         curs = self.conn.cursor()
00220         sqlstr = "SELECT RES_ID_SEQ.NextVal FROM DUAL"
00221         curs.prepare(sqlstr)
00222         curs.execute(sqlstr)
00223         for row in curs:
00224             return row[0]

def results_db::ResultsDB::getNewRunId (   self)

Definition at line 225 of file results_db.py.

00226                            :
00227         curs = self.conn.cursor()
00228         sqlstr = "SELECT RUN_ID_SEQ.NextVal FROM DUAL"
00229         curs.prepare(sqlstr)
00230         curs.execute(sqlstr)
00231         for row in curs:
00232             return row[0]

def results_db::ResultsDB::read (   self)

Definition at line 73 of file results_db.py.

00074                     :
00075         curs = self.conn.cursor()
00076         sqlstr = "SELECT RID, TO_CHAR(RDATE, 'DD.MM.YYYY HH24:MI:SS'), LABEL, T_RELEASE, T_ARCH "
00077         sqlstr +="FROM RUN_HEADER ORDER BY RID"
00078         curs.prepare(sqlstr)
00079         curs.execute(sqlstr)
00080         for row in curs:
00081             printRun( row )
00082             self.readRun( row[0] )

def results_db::ResultsDB::readResults (   self,
  id 
)

Definition at line 93 of file results_db.py.

00094                              :
00095         curs = self.conn.cursor()
00096         sqlstr = "SELECT STEP_LABEL, STATUS FROM RUN_STEP_RESULT WHERE ID = :ids"
00097         curs.prepare(sqlstr)
00098         curs.execute(sqlstr, ids = id)
00099         self.conn.commit()
00100         for row in curs:
00101             printStepResult( row )

def results_db::ResultsDB::readRun (   self,
  rid 
)

Definition at line 83 of file results_db.py.

00084                             :
00085         curs = self.conn.cursor()
00086         sqlstr = "SELECT ID, R_RELEASE, R_ARCH "
00087         sqlstr +="FROM RUN_RESULT WHERE RID=:rids ORDER BY ID"
00088         curs.prepare(sqlstr)
00089         curs.execute(sqlstr, rids=rid)
00090         for row in curs:
00091                 printResult( row )
00092                 self.readResults(row[0])
                    
def results_db::ResultsDB::readSelection (   self,
  runId,
  label,
  trel,
  tarch,
  full 
)

Definition at line 102 of file results_db.py.

00103                                                                :
00104         curs = self.conn.cursor()
00105         sqlstr = "SELECT RID, TO_CHAR(RDATE, 'DD.MM.YYYY HH24:MI:SS'), LABEL, T_RELEASE, T_ARCH, LOG "
00106         sqlstr +="FROM RUN_HEADER "
00107         putAnd = False
00108         if( runId != None ):
00109             sqlstr += "WHERE RID="+runId
00110             putAnd = True
00111         if( label != None ):
00112             if( putAnd == True ):
00113                 sqlstr += " AND "
00114             else:
00115                 sqlstr += "WHERE "
00116             sqlstr += "LABEL='"+label+"'"
00117             putAnd = True
00118         if( trel != None ):
00119             if( putAnd == True ):
00120                 sqlstr += " AND "
00121             else:
00122                 sqlstr += "WHERE "
00123             sqlstr += "T_RELEASE='"+trel+"'"
00124             putAnd = True
00125         if( tarch != None ):
00126             if( putAnd == True ):
00127                 sqlstr += " AND "
00128             else:
00129                 sqlstr += "WHERE "
00130             sqlstr += "T_ARCH='"+tarch+"'"
00131             putAnd = True
00132             sqlstr += " ORDER BY RID"
00133         print sqlstr
00134         curs.prepare(sqlstr)
00135         curs.execute(sqlstr)
00136         for row in curs:
00137             print '###########'
00138             print row[0]
00139             printRun( row )
00140             self.readRun( row[0] )
00141             if( full == True ):
00142                 if ( row[8]!=None ): 
00143                     print row[8].read()

def results_db::ResultsDB::writeResult (   self,
  runID,
  timeStamp,
  match,
  resTags 
)

Definition at line 165 of file results_db.py.

00166                                                            :
00167         curs = self.conn.cursor()
00168         sqlstr = "SELECT RID FROM RUN_HEADER WHERE RID = :rid"
00169         curs.prepare(sqlstr)
00170         curs.execute(sqlstr, rid = runID)
00171         foundRun = False
00172         for row in curs:
00173             foundRun = True
00174         if( foundRun == False ):
00175             sqlstr = "INSERT INTO RUN_HEADER(RID, RDATE, LABEL, T_RELEASE, T_ARCH) VALUES (:rid, :ts, :labl, :trel, :tarc)"
00176             curs.prepare(sqlstr)
00177             curs.execute(sqlstr, rid = runID, ts=timeStamp, labl=match[0], trel = match[1], tarc = match[2])    
00178         id = self.getNewResId()  
00179         sqlstr = "INSERT INTO RUN_RESULT(ID, RID, R_RELEASE, R_ARCH)"
00180         sqlstr +="VALUES(:ids, :rid, :rrel, :rarc)"
00181         curs.prepare(sqlstr)
00182         curs.execute(sqlstr, ids=id, rid = runID, rrel = match[3], rarc = match[4])
00183         self.conn.commit()
00184         for i in range(5, len(match)):
00185             if resTags[i-5] != "%NONE":
00186                 self.writeStepResult(id, resTags[i-5], match[i])

def results_db::ResultsDB::writeStepResult (   self,
  id,
  step_label,
  status 
)

Definition at line 187 of file results_db.py.

00188                                                      :
00189         curs = self.conn.cursor()
00190         sqlstr = "INSERT INTO RUN_STEP_RESULT(ID, STEP_LABEL, STATUS)"
00191         sqlstr +="VALUES(:ids, :labl, :stat)"
00192         curs.prepare(sqlstr)
00193         curs.execute(sqlstr, ids=id, labl=step_label, stat = status)
00194         self.conn.commit()


Member Data Documentation

Definition at line 30 of file results_db.py.