import subprocess import os,sys from ROOT import TFile,TH1F ### GLOBALS FILENAME = "dana_rest.hddm" NOMINAL_SIZE = 27200000. TOLERANCE = 0.05 # in percent DIRECTORY = "." # directory to search if __name__ == "__main__": if len(sys.argv) > 1: DIRECTORY = str(sys.argv[1]) rootfile = TFile("filesizes.root","recreate") h_filesizes = TH1F("filesizes", "Percentage of nominal file size", 120, 0, 120) for root, dirs, files in os.walk(DIRECTORY): for f in files: if f == FILENAME: filenamepath = os.path.join(root, f) filesize = os.path.getsize( filenamepath ) percentage_of_nominal_size = filesize/NOMINAL_SIZE h_filesizes.Fill( 100.*percentage_of_nominal_size ) if( abs(filesize-NOMINAL_SIZE)/NOMINAL_SIZE > TOLERANCE ): print " File size is bad (%3d%%): %s (%d)" % (100.*percentage_of_nominal_size, filenamepath, filesize) h_filesizes.Write() rootfile.Close()