Exemple #1
0
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=[]
		scan_item_load(os.path.join(dest_name,"scan_items.inp"))
		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 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)