def callback_remove_all_results(self, widget, data): results=[] return_file_list(results,self.sim_dir,"scan.inp") for i in range(0,len(results)): dir_name=os.path.dirname(results[i]) if os.path.isdir(dir_name): print "delete:",dir_name
def scan_gen_plot_data(plot_token, base_path): ret = "" plot_files = [] plot_labels = [] save_file = "" file_name = plot_token.file0 if file_name == "": print("You have given me no file name!!!") sys.exit(0) #search for the files return_file_list(plot_files, base_path, file_name) print("search_file=", plot_token.file0, file_name) print("plot_files0=", plot_files) #print("found_files=",plot_files) #print("found_files=",base_path) #now tidy up the list as we need to remove snapshots save_list = [] if base_path.split(os.sep).count("snapshots") == 0: for i in range(len(plot_files)): if "snapshots" not in plot_files[i]: save_list.append(plot_files[i]) plot_files = save_list print("plot_files=", plot_files) num_list = [] #remove the file name in the base_dir test_file = os.path.join(base_path, file_name) if test_file in plot_files: plot_files.remove(test_file) #attempt to sort list in numeric order try: for i in range(0, len(plot_files)): dir_name = os.path.basename(os.path.dirname(plot_files[i])) if dir_name == "dynamic": dir_name = os.path.basename( os.path.dirname(os.path.dirname(plot_files[i]))) num_list.append(float(dir_name)) num_list, plot_files = zip(*sorted(zip(num_list, plot_files))) except: print("There are stings in the list I can not order it") #if it is an info file then deal with it print(check_info_file(file_name), file_name, plot_token.file0, plot_token.file1, plot_token.tag0, plot_token.tag1) if (check_info_file(file_name) == True): #print "Rod",plot_files,self.sim_dir print(plot_files, "r", plot_labels, "r", save_file, "r", plot_files, "r", base_path, "r", plot_token) multi_plot = multiplot_from_tokens() plot_files, plot_labels, save_file = multi_plot.gen_plot( base_path, plot_token.file0, plot_token.tag0, plot_token.file1, plot_token.tag1) else: if len(plot_files) > 0: ret = plot_populate_plot_token(plot_token, plot_files[0]) if ret == False: error_dlg( self, "This file " + file_name + " is not in the data base please file a bug report..") return #build plot labels for i in range(0, len(plot_files)): text = plot_files[i][len(base_path):len(plot_files[i]) - 1 - len(os.path.basename(plot_files[i]))] if text.endswith("dynamic"): text = text[:-7] if text.endswith("optical_output"): text = text[:-10] if text[0] == "/" or "\\": text = text[1:] text = text.replace("\\", "/") plot_labels.append(str(text)) save_file = os.path.join( base_path, os.path.splitext(os.path.basename( plot_files[0]))[0]) + ".oplot" return plot_files, plot_labels, save_file
def scan_gen_plot_data(plot_token,base_path): ret="" plot_files=[] plot_labels=[] save_file="" file_name=plot_token.file0 if file_name=="": print("You have given me no file name!!!") sys.exit(0) #search for the files return_file_list(plot_files,base_path,file_name) print("search_file=",plot_token.file0) #print("found_files=",plot_files) #print("found_files=",base_path) #now tidy up the list as we need to remove snapshots save_list=[] if base_path.split(os.sep).count("snapshots")==0: for i in range(len(plot_files)): if "snapshots" not in plot_files[i]: save_list.append(plot_files[i]) plot_files=save_list print("plot_files=",plot_files) num_list=[] #remove the file name in the base_dir test_file=os.path.join(base_path,file_name) if test_file in plot_files: plot_files.remove(test_file) #attempt to sort list in numeric order try: for i in range(0, len(plot_files)): dir_name=os.path.basename(os.path.dirname(plot_files[i])) if dir_name=="dynamic": dir_name=os.path.basename(os.path.dirname(os.path.dirname(plot_files[i]))) num_list.append(float(dir_name)) num_list, plot_files = zip(*sorted(zip(num_list, plot_files))) except: print("There are stings in the list I can not order it") #if it is an info file then deal with it print(check_info_file(file_name),file_name,plot_token.file0,plot_token.file1,plot_token.tag0,plot_token.tag1) if (check_info_file(file_name)==True): #print "Rod",plot_files,self.sim_dir print(plot_files,"r",plot_labels,"r",save_file,"r",plot_files,"r",base_path,"r",plot_token) plot_files, plot_labels, save_file = gen_infofile_plot(plot_files,base_path,plot_token) else: ret=plot_populate_plot_token(plot_token,plot_files[0]) if ret==False: message = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK) message.set_markup("This file "+file_name+" is not in the data base please file a bug report..") message.run() message.destroy() return #build plot labels for i in range(0,len(plot_files)): text=plot_files[i][len(base_path):len(plot_files[i])-1-len(os.path.basename(plot_files[i]))] if text.endswith("dynamic"): text=text[:-7] if text.endswith("light_dump"): text=text[:-10] if text[0]=="/" or "\\": text=text[1:] text=text.replace("\\","/") plot_labels.append(str(text)) save_file=os.path.join(base_path,os.path.splitext(os.path.basename(plot_files[0]))[0])+".oplot" return plot_files, plot_labels, save_file