#!/usr/bin/env python # $Id: check_size.py,v 1.3 2003/11/24 15:31:26 hoeth Exp $ # Compare number events in DST, Thumbnail and Input files: # # check_size.py [DST_file_name |Thumbnail_file_name] # # Exits with $status = 0 if all three are equal # " " " = 1 if any of three are different # # Assumes that DST metadata files are in current # directory. Only works with non-selective processing. Also # assumes version is "p14...". I.e. won't work with "x14..." # files. # import sys, os, string # from posixpath import exists from file_client import * def getevents(filename): metafile = filename+".metadata.py" if(exists(metafile)): x = [] x = loadFileObjs(metafile, 1) if(len(x)<1): print "could not read metadata" return -1 object = x[0] return object.events.num else: command = "sam translate constraints --filename=%s | awk '/Event/{print $4}'"%filename result = os.popen(command).readlines() if(len(result) != 1): return -1 else: return string.atoi(result[0]) def check_size(filetocheck): ib = string.find(filetocheck,'reco_all') ie = string.find(filetocheck,'_p14') inputfile = filetocheck[ib:ie] dstfile = 'reco_'+filetocheck[ib:] inpevents = getevents(inputfile) dstevents = getevents(dstfile) if ( (inpevents != dstevents) ): print "Error: input, dst: ",inpevents,dstevents return 1 else: print "OK: input, dst: ",inpevents,dstevents return 0 if __name__ == '__main__': filetocheck = sys.argv[1] sys.exit(check_size(filetocheck))