def scan_nested_simulation(root_simulation,nest_simulation): a=tree_gen_flat_list(root_simulation,level=1) print(a) return program_list=tree_load_program(nest_simulation) names=tree_load_flat_list(root_simulation) commands=[] flat_simulation_list=[] #tree_save_flat_list(self.sim_dir,flat_simulation_list) for i in range(0,len(names)): dest_name=os.path.join(root_simulation,names[i]) tree_gen(flat_simulation_list,program_list,dest_name,dest_name) files = os.listdir(dest_name) for file in files: if file.endswith(".inp") or file.endswith(".gpvdm") or file.endswith(".dat") : os.remove(os.path.join(dest_name,file)) print(names[i],flat_simulation_list) tree_save_flat_list(root_simulation,flat_simulation_list) return
def scan_build_nested_simulation(root_simulation, nest_simulation): if os.path.isdir(nest_simulation) == False: print("Path ", nest_simulation, "does not exist") sys.exit(0) progress_window = progress_class() progress_window.show() progress_window.start() process_events() nest_simulation_name = os.path.basename(nest_simulation) program_list = tree_load_program(nest_simulation) files = os.listdir(root_simulation) simulations = [] for i in range(0, len(files)): if os.path.isfile(os.path.join(root_simulation, files[i], "sim.gpvdm")) == True: simulations.append(files[i]) flat_simulation_list = [] path = os.getcwd() for i in range(0, len(simulations)): dest_name = os.path.join(root_simulation, simulations[i], nest_simulation_name) base_dir = os.path.join(root_simulation, simulations[i]) #print(">>>",dest_name,base_dir,"<<",nest_simulation_name) tree_gen(dest_name, flat_simulation_list, program_list, base_dir) progress_window.set_fraction(float(i) / float(len(simulations))) progress_window.set_text(simulations[i]) process_events() progress_window.stop() os.chdir(path) flat_simulation_list = tree_gen_flat_list(root_simulation, level=1) #print(flat_simulation_list) tree_save_flat_list(root_simulation, flat_simulation_list) return
def scan_nested_simulation(root_simulation,nest_simulation): names=tree_load_flat_list(root_simulation) commands=[] for i in range(0,len(names)): dest_name=os.path.join(names[i],os.path.basename(nest_simulation)) copy_scan_dir(dest_name,nest_simulation) program_list=[] flat_list=[] tree_load_program(program_list,dest_name) print("call=",names[i],dest_name) tree_gen(flat_list,program_list,names[i],dest_name) server_find_simulations_to_run(commands,dest_name) return commands
def build_scan(scan_path,base_path,parent_window=None): scan_clean_dir(scan_path,parent_window=parent_window) flat_simulation_list=[] program_list=tree_load_program(scan_path) path=os.getcwd() if tree_gen(flat_simulation_list,program_list,base_path,scan_path)==False: error_dlg(parent_window,_("Problem generating tree.")) return False os.chdir(path) tree_save_flat_list(scan_path,flat_simulation_list)
def scan_build_nested_simulation(root_simulation, nest_simulation): progress_window = progress_class() progress_window.show() progress_window.start() process_events() program_list = tree_load_program(nest_simulation) files = os.listdir(root_simulation) simulations = [] for i in range(0, len(files)): if os.path.isfile(os.path.join(root_simulation, files[i], "sim.gpvdm")) == True: simulations.append(files[i]) flat_simulation_list = [] path = os.getcwd() for i in range(0, len(simulations)): dest_name = os.path.join(root_simulation, simulations[i]) tree_gen(flat_simulation_list, program_list, dest_name, dest_name) progress_window.set_fraction(float(i) / float(len(simulations))) progress_window.set_text(simulations[i]) process_events() progress_window.stop() os.chdir(path) flat_simulation_list = tree_gen_flat_list(root_simulation, level=1) print(flat_simulation_list) tree_save_flat_list(root_simulation, flat_simulation_list) return
def build_scan(self): self.clean_dir() flat_simulation_list = [] path = os.getcwd() #print(self.scan_dir,flat_simulation_list,self.program_list,self.base_dir) if tree_gen(self.scan_dir, flat_simulation_list, self.program_list, self.base_dir) == False: error_dlg(self.parent_window, _("Problem generating tree.")) return False os.chdir(path) tree_save_flat_list(self.scan_dir, flat_simulation_list)
def simulate(self,run_simulation,generate_simulations,args): base_dir=os.getcwd() run=True if self.tab.rowCount() == 0: error_dlg(self,_("You have not selected any parameters to scan through. Use the add button.")) return if self.sim_name=="": error_dlg(self,_("No sim dir name")) return self.make_sim_dir() if generate_simulations==True: scan_clean_dir(self,self.sim_dir) print("Running") program_list=[] for i in range(0,self.tab.rowCount()): program_list.append([tab_get_value(self.tab,i,0),tab_get_value(self.tab,i,1),tab_get_value(self.tab,i,3),tab_get_value(self.tab,i,4)]) print(program_list) tree_load_config(self.sim_dir) if generate_simulations==True: flat_simulation_list=[] if tree_gen(flat_simulation_list,program_list,base_dir,self.sim_dir)==False: error_dlg(self,_("Problem generating tree.")) return print("flat list",flat_simulation_list) tree_save_flat_list(self.sim_dir,flat_simulation_list) commands=tree_load_flat_list(self.sim_dir) print("loaded commands",commands) if run_simulation==True: self.send_commands_to_server(commands,args) self.save_combo() os.chdir(base_dir) gc.collect()
def simulate(self,run_simulation,generate_simulations): base_dir=os.getcwd() run=True if len(self.liststore_combobox) == 0: message = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK) message.set_markup(_("You have not selected any parameters to scan through. Use the add button.")) message.run() message.destroy() return if self.sim_name=="": message = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK) message.set_markup(_("No sim dir name")) message.run() message.destroy() return self.make_sim_dir() if generate_simulations==True: scan_clean_dir(self.sim_dir) for i in range(0,len(self.liststore_combobox)): found=False for ii in range(0,len(self.liststore_op_type)): if self.liststore_combobox[i][2]==self.liststore_op_type[ii][0]: found=True if found==False: run=False md = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, self.liststore_combobox[i][2]+"Not valid") md.run() md.destroy() break if run==True: print "Running" program_list=[] for i in range(0,len(self.liststore_combobox)): program_list.append([self.liststore_combobox[i][0],self.liststore_combobox[i][1],self.liststore_combobox[i][2],self.liststore_combobox[i][3]]) print program_list if generate_simulations==True: flat_simulation_list=[] tree_gen(flat_simulation_list,program_list,base_dir,self.sim_dir) print "flat list",flat_simulation_list tree_save_flat_list(self.sim_dir,flat_simulation_list) commands=[] server_find_simulations_to_run(commands,self.sim_dir) if run_simulation==True: self.send_commands_to_server(commands) self.save_combo() os.chdir(base_dir) gc.collect()
def command_args(argc,argv): if argc>=2: if argv[1]=="--help": print "Usage: opvdm [option] src_file dest_file" print "" print "Options:" print "\t--version\tdisplays the current version" print "\t--help\t\tdisplays the help" print "\t--export\texport a simulation to a gz file" print "\t--import\timport a simulation from a .opvdm file" print "\t--patch\tpatch an .opvdm file with an older .opvdm file" print "\t\t\tusage --import abc.opvdm ./path/to/output/ " print "\t--clone\t\tgenerate a clean simulation in the current directory" print "\t--clean\t\tcleans the current simulation directory deleting .dat files and scan dirs" print "\t--dump-tab (output file)\t\tdumps simulation parameters as jpg" print "\t--import-scandirs\t\tOnly imports the scan directories" print "\t--clean-scandirs\t\tDeletes the content of all scan dirs" print "\t--scan-plot\t\truns an oplot file" print "\t\t\tusage --scan-plot /path/to/oplot/file.oplot " print "\t--run-scan\t\truns a scan" print "\t\t\tusage --run-scan /path/containing/base/files/ /path/to/scan/dir/ " print "" print "Additional information about opvdm is available at http://www.opvdm.com." print "" print "Report bugs to: [email protected]" sys.exit(0) if argv[1]=="--version": print ver() sys.exit(0) if argv[1]=="--import-scandirs": import_scan_dirs(os.getcwd(),argv[2]) exit(0) if argv[1]=="--export": export_as(argv[2]) sys.exit(0) if argv[1]=="--dump-tab": export_as(argv[2]) sys.exit(0) if argv[1]=="--import": import_archive(argv[2],os.path.join(os.getcwd(),"sim.opvdm"),False) sys.exit(0) if argv[1]=="--patch": import_archive(argv[2],argv[3],True) sys.exit(0) if argv[1]=="--clone": opvdm_clone() sys.exit(0) if argv[1]=="--clone-src": opvdm_copy_src(argv[2]) sys.exit(0) if argv[1]=="--file_info": data=plot_data() data.dump_file() sys.exit(0) if argv[1]=="--clean": clean_sim_dir() sys.exit(0) if argv[1]=="--clean-scandirs": clean_scan_dirs(os.getcwd()) sys.exit(0) if argv[1]=="--server": obj=udp_server() obj.start() if argv[1]=="--client": client=udp_client() client.init() if argv[1]=="--make-man": make_man() sys.exit(0) if argv[1]=="--run-scan": scan_dir_path=argv[3] #program file program_list=[] base_dir=argv[2] #base dir exe_command = get_exe_command() scan_item_load(os.path.join(scan_dir_path,"scan_items.inp")) tree_load_program(program_list,scan_dir_path) watch_dir=os.path.join(os.getcwd(),scan_dir_path) #print program_list,pwd,scan_dir_path #sys.exit(0) #print pwd,scan_dir_path #print os.getcwd(),os.path.join(scan_dir_path) #tree_gen(program_list,os.getcwd(),os.path.join(os.getcwd(),"suns")) flat_list=[] tree_gen(flat_list,program_list,base_dir,scan_dir_path) commands=[] server_find_simulations_to_run(commands,scan_dir_path) myserver=server() myserver.init(watch_dir) myserver.clear_cache() for i in range(0, len(commands)): myserver.add_job(commands[i]) print "Adding job"+commands[i] myserver.simple_run(exe_command) sys.exit(0) if argv[1]=="--scan-plot": plot_token=plot_state() oplot_file=argv[2] if plot_load_info(plot_token,oplot_file)==True: print "file0=",plot_token.file0,"<" plot_files, plot_labels, save_file = scan_gen_plot_data(plot_token,os.path.dirname(oplot_file)) print "written data to",save_file else: print "Problem loading oplot file" sys.exit(0)
def command_args(argc,argv): if argc>=2: if argv[1]=="--help": print(_("Usage: gpvdm [option] src_file dest_file")) print("") print(_("Options:")) print(_("\t--version\t\tdisplays the current version")) print(_("\t--help\t\t\tdisplays the help")) print(_("\t--export\t\texport a simulation to a gz file")) print(_("\t--import\t\timport a simulation from a .gpvdm file")) print(_("\t--patch\t\t\tpatch an .gpvdm file with an older .gpvdm file")) print(_("\t\t\t\tusage --import abc.gpvdm ./path/to/output/ ")) print(_("\t--clone\t\t\tgenerate a clean simulation in the current directory")) print(_("\t--clean\t\t\tcleans the current simulation directory deleting .dat files but not scan dirs")) print(_("\t--dump-tab\t\tdumps simulation parameters as jpg")) print(_("\t\t\t\tusage --dump-tab output_path ")) print(_("\t--import-scandirs\tOnly imports the scan directories")) print(_("\t--clean-scandirs\tDeletes the content of all scan dirs")) print(_("\t--scan-plot\t\truns an oplot file")) print(_("\t\t\t\tusage --scan-plot /path/to/oplot/file.oplot ")) print(_("\t--run-scan\t\truns a scan")) print(_("\t\t\t\tusage --run-scan /path/containing/base/files/ /path/to/scan/dir/ ")) print(_("\t--sync-ver\t\truns a scan")) print(_("\t--edit-value\t\tedits a value in a .gpvdm archive")) print(_("\t\t\t\tusage --edit-value /path/to/sim.gpvdm #token_to_change new_value ")) print(_("\t\t\t\tchanges the version of input file")) print(_("\t--replace\t\treplaces file in device lib")) if enable_cluster()==True: print(_("\t--server\t\tRun as server node for cluster")) print(_("\t--server\t\tRun as client node for cluster")) print("\t\t\t") print("") print(_("Additional information about gpvdm is available at http://www.gpvdm.com.")) print("") print(_("Report bugs to: [email protected]")) sys.exit(0) if check_params(argv,"--version",0)==True: print(version()) sys.exit(0) if check_params(argv,"--ver",0)==True: print(ver()) sys.exit(0) if check_params(argv,"--import-scandirs",1)==True: import_scan_dirs(os.getcwd(),argv[2]) exit(0) if check_params(argv,"--replace",1)==True: device_lib_replace(argv[2]) exit(0) if check_params(argv,"--export",1)==True: export_as(argv[2]) sys.exit(0) if check_params(argv,"--dump-tab",1)==True: export_as(argv[2]) sys.exit(0) if check_params(argv,"--import",1)==True: import_archive(argv[2],os.path.join(os.getcwd(),"sim.gpvdm"),False) sys.exit(0) if check_params(argv,"--patch",2)==True: import_archive(argv[2],argv[3],True) sys.exit(0) if check_params(argv,"--clone",0)==True: gpvdm_clone(os.getcwd(),True) sys.exit(0) if check_params(argv,"--clone-src",1)==True: gpvdm_copy_src(argv[2]) sys.exit(0) if check_params(argv,"--edit-value",3)==True: inp_update(argv[2], argv[3], argv[4]) sys.exit(0) #if check_params(argv,"--file_info",0)==True: # data=plot_data() # data.dump_file() # sys.exit(0) if check_params(argv,"--clean",0)==True: clean_sim_dir() sys.exit(0) if check_params(argv,"--clean-scandirs",0)==True: clean_scan_dirs(os.getcwd()) sys.exit(0) if check_params(argv,"--make-man",1)==True: make_man() sys.exit(0) if check_params(argv,"--sync-ver",0)==True: ver_sync_ver() sys.exit(0) if check_params(argv,"--run-scan",2)==True: scan_dir_path=argv[3] #program file program_list=[] base_dir=argv[2] #base dir exe_command = get_exe_command() tree_load_program(program_list,scan_dir_path) watch_dir=os.path.join(os.getcwd(),scan_dir_path) #print(program_list,pwd,scan_dir_path) #sys.exit(0) #print(pwd,scan_dir_path) #print(os.getcwd(),os.path.join(scan_dir_path)) #tree_gen(program_list,os.getcwd(),os.path.join(os.getcwd(),"suns")) flat_list=[] tree_gen(flat_list,program_list,base_dir,scan_dir_path) commands=[] server_find_simulations_to_run(commands,scan_dir_path) myserver=server() myserver.init(watch_dir) myserver.clear_cache() for i in range(0, len(commands)): myserver.add_job(commands[i],"") print("Adding job"+commands[i]) myserver.simple_run(exe_command) sys.exit(0) if check_params(argv,"--scan-plot",1)==True: plot_token=plot_state() oplot_file=argv[2] if plot_load_info(plot_token,oplot_file)==True: print("file0=",plot_token.file0,"<") plot_files, plot_labels, save_file = scan_gen_plot_data(plot_token,os.path.dirname(oplot_file)) print("written data to",save_file) else: print("Problem loading oplot file") sys.exit(0)