예제 #1
0
    def testGlobLast(self):
        globPattern = os.path.join(cingRoot, '*.txt')
        lastFile = globLast(globPattern)
        nTdebug('lastFile: %s' % lastFile)
        d, _basename, extension = nTpath(lastFile)
        self.assertTrue(lastFile)
        self.assertEquals(d, cingRoot)
        self.assertEquals(extension, '.txt')

        globPattern = os.path.join(cingRoot, '*.xyz')
        lastFile = globLast(globPattern)
        nTdebug('lastFile 2: %s' % lastFile)
        self.assertFalse(lastFile)
예제 #2
0
    def testGlobLast(self):
        globPattern = os.path.join(cingRoot, '*.txt')
        lastFile = globLast(globPattern)
        nTdebug('lastFile: %s' % lastFile)
        d, _basename, extension = nTpath(lastFile)
        self.assertTrue(lastFile)
        self.assertEquals(d, cingRoot)
        self.assertEquals(extension, '.txt')

        globPattern = os.path.join(cingRoot, '*.xyz')
        lastFile = globLast(globPattern)
        nTdebug('lastFile 2: %s' % lastFile)
        self.assertFalse(lastFile)
예제 #3
0
    def testGetDateTimeStampForFileName(self):
        globPattern = os.path.join(cingRoot, '*.txt')
        lastFile = globLast(globPattern)
        dateTimeObject = getDateTimeFromFileName(lastFile)
#        dateTimeString = getDateTimeStampForFileName(lastFile)
#        nTdebug('lastFile: %s dateTimeObject %s' % (lastFile, dateTimeObject))
#        nTdebug('lastFile: %s dateTimeString %s' % (lastFile, dateTimeString))
        self.assertTrue(dateTimeObject)
        self.assertTrue(dateTimeObject.year >= 2009)
예제 #4
0
 def testGetDateTimeStampForFileName(self):
     globPattern = os.path.join(cingRoot, '*.txt')
     lastFile = globLast(globPattern)
     dateTimeObject = getDateTimeFromFileName(lastFile)
     #        dateTimeString = getDateTimeStampForFileName(lastFile)
     #        nTdebug('lastFile: %s dateTimeObject %s' % (lastFile, dateTimeObject))
     #        nTdebug('lastFile: %s dateTimeString %s' % (lastFile, dateTimeString))
     self.assertTrue(dateTimeObject)
     self.assertTrue(dateTimeObject.year >= 2009)
예제 #5
0
def checkCingLogForErrors(entry_code,
                          results_dir,
                          log_dir,
                          requiresLogFilePresent=True,
                          maxErrors=0):
    '''
    Scan last CING log for errors. 
    Input log_dir is local to entry directory.
    The results_dir is an absolute path.
    return None on all is good.
    return True on error.
    '''
    #    print 'Now in %s for entry_code %s' % ( getCallerName(), entry_code )
    entryCodeChar2and3 = entry_code[1:3]
    logDir = os.path.join(results_dir, DATA_STR, entryCodeChar2and3,
                          entry_code, log_dir)
    if not os.path.exists(logDir):
        print "ERROR: Failed to find log dir: %s" % logDir
        return True
    # end if
    logLastFile = globLast(logDir + '/*.log')
    #            nTdebug("logLastFile: %s" % logLastFile)
    if not logLastFile:
        if requiresLogFilePresent:
            print "ERROR: Failed to find any prep log file in directory: %s" % logDir
            return True
        # end if
        return
    # end if
    analysisResultTuple = analyzeCingLog(logLastFile)
    if not analysisResultTuple:
        print "ERROR: Failed to analyze log file: %s" % logLastFile
        return True
    # end if
    timeTaken, entryCrashed, nr_error, nr_warning, nr_message, nr_debug = analysisResultTuple
    if entryCrashed:
        print "ERROR: Detected a crash: %s in %s" % (entry_code, logLastFile)
        return True
    # end if
    if not timeTaken:
        print "ERROR: Unexpected [%s] for time taken in CING prep log file: %s assumed crashed." % (
            timeTaken, logLastFile)
        return True
    # end if
    if nr_error > maxErrors:
        msg = "For %s found %s/%s timeTaken/entryCrashed and %d/%d/%d/%d error,warning,message, and debug lines." % (
            entry_code, timeTaken, entryCrashed, nr_error, nr_warning,
            nr_message, nr_debug)
        print "ERROR: " + msg + " Please check: " + logLastFile
        return True
    # end if
    print "Checked: " + logLastFile
    return
예제 #6
0
def checkCingLogForErrors( entry_code, results_dir, log_dir, requiresLogFilePresent = True, maxErrors = 0 ):
    '''
    Scan last CING log for errors. 
    Input log_dir is local to entry directory.
    The results_dir is an absolute path.
    return None on all is good.
    return True on error.
    '''
#    print 'Now in %s for entry_code %s' % ( getCallerName(), entry_code )
    entryCodeChar2and3 = entry_code[1:3]
    logDir = os.path.join( results_dir, DATA_STR, entryCodeChar2and3, entry_code, log_dir )
    if not os.path.exists(logDir):
        print "ERROR: Failed to find log dir: %s" % logDir
        return True
    # end if    
    logLastFile = globLast(logDir + '/*.log')
#            nTdebug("logLastFile: %s" % logLastFile)
    if not logLastFile:
        if requiresLogFilePresent:
            print "ERROR: Failed to find any prep log file in directory: %s" % logDir
            return True
        # end if                            
        return
    # end if            
    analysisResultTuple = analyzeCingLog(logLastFile)
    if not analysisResultTuple:
        print "ERROR: Failed to analyze log file: %s" % logLastFile
        return True
    # end if                    
    timeTaken, entryCrashed, nr_error, nr_warning, nr_message, nr_debug = analysisResultTuple
    if entryCrashed:
        print "ERROR: Detected a crash: %s in %s" % (entry_code, logLastFile)
        return True
    # end if
    if not timeTaken:
        print "ERROR: Unexpected [%s] for time taken in CING prep log file: %s assumed crashed." % (timeTaken, logLastFile)
        return True
    # end if
    if nr_error > maxErrors:
        msg = "For %s found %s/%s timeTaken/entryCrashed and %d/%d/%d/%d error,warning,message, and debug lines." % (
            entry_code, timeTaken, entryCrashed, nr_error, nr_warning, nr_message, nr_debug)
        print "ERROR: " + msg + " Please check: " + logLastFile
        return True
    # end if
    print "Checked: " + logLastFile
    return