def check(job, period): """Check log files for errors and warnings""" global options success = True print "Checking job", job basedir = ara.config.get('Analysis', 'basedir') myDir = basedir + '/' + options.selection + '/' + period errors = [ "exception", "segmentation", "error", "err:" ] warnings = [ "warning", "wrn" ] requirements = [ "End executing" ] # Find all job files from directory jobfiles = [] for filename in os.listdir(myDir): if filename.startswith(job+'_') and filename.endswith("_condor.cfg"): jobfiles.append(filename[:filename.find("_condor.cfg")]) if len(jobfiles) == 0: print 'Error, no job files found for process', job return False # Check all job files good = True for filename in jobfiles: success = ara.check_log(myDir+'/'+filename+"_stdout.log", errors, warnings, requirements) if not success: good = False if (options.resubmit): resubmit(filename, period) else: success = ara.check_log(myDir+'/'+filename+"_stderr.log", errors, warnings, None) if not success: good = False if (options.resubmit): resubmit(filename, period) return good
def main(): optParser = optparse.OptionParser() optParser.add_option( "-c", "--config", dest="cfgfile", help="global configuration file", default=ara.defaultConfigFileName ) (options, args) = optParser.parse_args() if len(args) < 1: optParser.print_help() return 1 ara.config.read(options.cfgfile) errors = ["exception", "segmentation", "error", "err:"] warnings = ["warning", "wrn"] requirements = ["End executing"] # check log files on command line for arg in args: if not ara.check_log(arg, errors, warnings, requirements): return 1 return 0