Changeset 347


Ignore:
Timestamp:
23/06/15 17:50:35 (5 years ago)
Author:
astephen
Message:

Updated summary.py as follows:

  • renamed class "main" to "LogSummariser?"
  • changed class interactions so "summarise()" method is used to run it
  • added convenience function to wrap initiate class and call "summarise()" method.
  • added comments to allow all FAILED files to be listed in summary
    • this can be added as a command-line switch later.
Location:
CCCC/trunk/ceda_cc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CCCC/trunk/ceda_cc/c4.py

    r332 r347  
    1818  if sys.argv[1] == '--sum': 
    1919      import summary 
    20       summary.main() 
     20      summary.summariseLogs() 
    2121  elif sys.argv[1] == '-v': 
    2222      from versionConfig import version, versionComment 
  • CCCC/trunk/ceda_cc/c4_run.py

    r327 r347  
    1717     if sys.argv[1] == '--sum': 
    1818        import summary 
    19         summary.main() 
     19        summary.summariseLogs() 
    2020        raise SystemExit(0) 
    2121     elif sys.argv[1] == '-v': 
  • CCCC/trunk/ceda_cc/summary.py

    r223 r347  
    1111class errorShortNames(object): 
    1212 
    13   def __init__(self,file='config/testStandardNames.txt' ): 
     13  def __init__(self, file='config/testStandardNames.txt'): 
    1414    assert os.path.isfile(file), 'File %s not found' % file 
    1515    ii = map( string.strip, open(file).readlines() ) 
     
    3333    return min(x,y) 
    3434 
    35 class main(object): 
     35class LogSummariser(object): 
    3636 
    3737  def __init__(self): 
     38    pass 
     39 
     40  def summarise(self): 
    3841    args = sys.argv[1:-1] 
    3942    idir = sys.argv[-1] 
     
    4851    assert os.path.isdir( idir ), 'Directory %s not found' % idir 
    4952 
    50     fl = glob.glob( '%s/*__qclog_*.txt' % idir ) 
    5153    fb = glob.glob( '%s/qcBatchLog*' % idir ) 
    5254    fb.sort() 
     
    5456    ii = open( fb ) 
    5557    jj = [] 
     58 
    5659    for k in range(10): 
    5760      jj.append( string.strip(ii.readline()) ) 
     
    6669 
    6770    ee = {} 
     71 
     72    fl = glob.glob( '%s/*__qclog_*.txt' % idir ) 
    6873    self.write( 'Summarising error reports from %s log file' % len(fl) ) 
    6974    nne = 0 
    7075    nerr = 0 
    7176    ff = {} 
     77 
    7278    for f in fl: 
    7379      nef = 0 
     
    7581      for l in open(f).readlines(): 
    7682        fn = string.split(f,'/')[-1] 
    77         if (l[:3] == 'C4.' and string.find(l, 'FAILED') != -1) or string.find(l,'CDMSError:') != -1: 
     83        if (l[:3] in ('C4.', 'C5.') and l.find('FAILED') > -1) or l.find('CDMSError:') > -1: 
    7884          nef += 1 
    7985          nerr += 1 
     
    116122      if len(ks) == 1: 
    117123        self.write( '%s:  %s  %s' % (k,ee[k][0],ks[0]) ) 
     124 
     125        # Show first set of files that failed [To show them all change to: range(len(ee[k][1][ks[0]][1])) ] 
    118126        for i in range(cmin(ndisp,ee[k][0])): 
    119127          self.write( '               %s' % ee[k][1][ks[0]][1][i] ) 
     
    123131        for k2 in ks: 
    124132          self.write( '  --- %s: %s' % (k2,ee[k][1][k2][0]) ) 
     133 
     134          # Show first set of files that failed [To show them all change to: range(len(ee[k][1][k2][1])) 
    125135          for i in range(cmin(ndisp,ee[k][1][k2][0])): 
    126136            self.write( '               %s' % ee[k][1][k2][1][i] ) 
     
    155165    for t in self.tests: 
    156166      self.testdict[t[0]] = (t[1],t[2]) 
    157      
     167 
    158168  def write( self, s ): 
    159169    print s 
     
    168178             </p> 
    169179             ''' % (l.name,l.name, l.long_name, l.description ) 
    170      
     180 
    171181    self.__htmlPageWrite( 'html/ref/errorShortNames.html', cnt ) 
    172182 
     
    275285    oo.close() 
    276286 
     287def summariseLogs(): 
     288    summariser = LogSummariser() 
     289    summariser.summarise() 
     290 
    277291if __name__ == '__main__': 
    278   main() 
     292 
     293  summariseLogs() 
Note: See TracChangeset for help on using the changeset viewer.