Esempio n. 1
0
def export_materials(target):
	if target.endswith(".zip")==False:
		target=target+".zip"

	file_list=[]

	progress_window=progress_class()
	progress_window.show()
	progress_window.start()
	process_events()
	mat_files=["alpha_eq.inp","alpha_gen.omat","alpha.omat","cost.xlsx","dos.inp","fit.inp","mat.inp","n_eq.inp","n_gen.omat","n.omat","pl.inp"]
	for path, dirs, files in os.walk(os.path.join(os.getcwd(),"materials")):
		for file_name in files:
			if file_name in mat_files:
				file_list.append(os.path.join(path,file_name))

	zf = zipfile.ZipFile(target, 'a')

	for i in range(0,len(file_list)):
		cur_file=file_list[i]

		lines=[]
		if os.path.isfile(cur_file):
			f=open(cur_file, mode='rb')
			lines = f.read()
			f.close()


			zf.writestr(remove_cwdfrompath(cur_file), lines)
			progress_window.set_fraction(float(i)/float(len(file_list)))
			progress_window.set_text("Adding"+cur_file[len(os.getcwd()):])
			process_events()

	zf.close()
	progress_window.stop()
def export_materials(target):
	if target.endswith(".zip")==False:
		target=target+".zip"

	file_list=[]

	progress_window=progress_class()
	progress_window.show()
	progress_window.start()
	process_events()
	mat_files=["alpha_eq.inp","alpha_gen.omat","alpha.omat","cost.xlsx","dos.inp","fit.inp","info.txt","mat.inp","n_eq.inp","n_gen.omat","n.omat","pl.inp"]
	for path, dirs, files in os.walk(os.path.join(os.getcwd(),"materials")):
		for file_name in files:
			if file_name in mat_files:
				file_list.append(os.path.join(path,file_name))

	zf = zipfile.ZipFile(target, 'a')

	for i in range(0,len(file_list)):
		cur_file=file_list[i]

		lines=[]
		if os.path.isfile(cur_file):
			f=open(cur_file, mode='rb')
			lines = f.read()
			f.close()


			zf.writestr(remove_cwdfrompath(cur_file), lines)
			progress_window.set_fraction(float(i)/float(len(file_list)))
			progress_window.set_text("Adding"+cur_file[len(os.getcwd()):])
			process_events()

	zf.close()
	progress_window.stop()
Esempio n. 3
0
def export_archive(target,everything):
	if target.endswith(".opvdm")==False:
		target=target+".opvdm"

	file_list=[]

	progress_window=progress_class()
	progress_window.init()
	progress_window.show()
	progress_window.start()
	process_events()
	   
	if everything==True:
		for path, dirs, files in os.walk(os.getcwd()):	
			for file_name in files:
				if file_name.endswith(".inp") or file_name.endswith(".dat") or file_name.endswith(".omat"):  
					file_list.append(os.path.join(path,file_name))
	else:
		files=os.listdir(os.getcwd())
		for file_name in files:
			if file_name.endswith(".inp"):  
				file_list.append(os.path.join(os.getcwd(),file_name))

	zf = zipfile.ZipFile(target, 'a')

	for i in range(0,len(file_list)):
		cur_file=file_list[i]

		lines=[]
		if os.path.isfile(cur_file):
			f=open(cur_file, mode='rb')
			lines = f.read()
			f.close()


			zf.writestr(remove_cwdfrompath(cur_file), lines)
			progress_window.set_fraction(float(i)/float(len(file_list)))
			progress_window.set_text("Adding"+cur_file[len(os.getcwd()):])
			process_events()

	src_zf = zipfile.ZipFile(os.path.join(os.getcwd(),"sim.opvdm"), 'r')

	for file_name in src_zf.namelist():
		if file_name not in zf.namelist():
			#print "adding from archive",file_name
			lines=src_zf.read(file_name)
			zf.writestr(file_name, lines)

	zf.close()
	src_zf.close()
	progress_window.stop()