def run(self): this_dir=DirID(self.directory.name,self.depth) if this_dir in self.black_list: print "Skipping %s since blacklisted!" %this_dir return 0 self.depth+=1 the_test=Statistical_Tests[self.stat_test](self.test_threshold) #print "Test %s with threshold %s" %(self.stat_test,self.test_threshold) directory1=self.base1+"/"+self.directory.mother_dir+"/"+self.directory.name directory2=self.base2+"/"+self.directory.mother_dir+"/"+self.directory.name fetchers =(DirFetcher(self.comm1,directory1),DirFetcher(self.comm2,directory2)) for fetcher in fetchers: fetcher.start() for fetcher in fetchers: fetcher.join() contents1 = fetchers[0].contents contents2 = fetchers[1].contents set1= set(contents1.keys()) set2= set(contents2.keys()) walkers=[] self_directory_directories=self.directory.subdirs self_directory_comparisons=self.directory.comparisons contents_names=list(set1.intersection(set2)) for name in contents_names: content = contents1[name] if "dir" in content["type"]: #if this_dir not in DirWalker.white_list:continue subdir=Directory(name,join(self.directory.mother_dir,self.directory.name)) dirwalker=DirWalkerDB(self.comm1,self.comm2,self.base1,self.base2,subdir,self.depth, self.do_pngs,self.stat_test,self.test_threshold,self.black_list) dirwalker.start() walkers.append(dirwalker) n_threads=activeCount() if n_threads>5: #print >> stderr, "Threads that are running: %s. Joining them." %(n_threads) dirwalker.join() elif content["kind"]=="ROOT": # print directory1,name comparison=Comparison(name, join(self.directory.mother_dir,self.directory.name), literal2root(content["obj_as_string"],content["type"]), literal2root(contents2[name]["obj_as_string"],content["type"]), deepcopy(the_test), do_pngs=self.do_pngs) self_directory_comparisons.append(comparison) for walker in walkers: walker.join() walker_directory=walker.directory if not walker_directory.is_empty(): self_directory_directories.append(walker_directory)
def __fill_single_dir(self, dir_name, directory, mother_name="", depth=0): #print "MOTHER NAME = +%s+" %mother_name #print "About to study %s (in dir %s)" %(dir_name,getcwd()) # see if in black_list this_dir = DirID(dir_name, depth) #print this_dir if this_dir in self.black_list: #print "Directory %s skipped because black-listed" %dir_name return 0 depth += 1 self.cd(dir_name) #print self.ls() #print "Test %s with thre %s" %(self.stat_test.name, self.stat_test.threshold) contents = self.ls() if depth == 1: n_top_contents = len(contents) #print contents cont_counter = 1 comparisons = [] for name, obj_type in contents.items(): if obj_type == "TDirectoryFile": #We have a dir, launch recursion! #Some feedback on the progress if depth == 1: print "Studying directory %s, %s/%s" % (name, cont_counter, n_top_contents) cont_counter += 1 #print "Studying directory",name # ok recursion on! subdir = Directory(name) subdir.draw_success = directory.draw_success subdir.do_pngs = directory.do_pngs self.__fill_single_dir(name, subdir, join(mother_name, dir_name), depth) if not subdir.is_empty(): if depth == 1: print " ->Appending %s..." % name, directory.subdirs.append(subdir) if depth == 1: print "Appended." else: # We have probably an histo. Let's make the plot and the png. if obj_type[:2] != "TH" and obj_type[:3] != "TPr": continue h1, h2 = self.getObjs(name) #print "COMPARISON : +%s+%s+" %(mother_name,dir_name) path = join(mother_name, dir_name, name) if path in self.black_list_histos: print " Skipping %s" % (path) directory.comparisons.append( Comparison(name, join(mother_name, dir_name), h1, h2, deepcopy(self.stat_test), draw_success=directory.draw_success, do_pngs=directory.do_pngs, skip=True)) else: directory.comparisons.append( Comparison(name, join(mother_name, dir_name), h1, h2, deepcopy(self.stat_test), draw_success=directory.draw_success, do_pngs=directory.do_pngs, skip=False)) self.cd("..")