コード例 #1
0
ファイル: scan_tree.py プロジェクト: roderickmackenzie/opvdm
def copy_simulation(base_dir, cur_dir):
    param_list = scan_items_get_list()
    cache = int(inp_get_token_value("server.inp", "#use_cache"))

    if cache == True:
        cache_path = get_cache_path(cur_dir)
        d = os.path.dirname(cache_path)

        if os.path.isdir(cache_path) == True:
            shutil.rmtree(cache_path)  # if there is something in the cache with this name remove it

        if not os.path.exists(cache_path):
            os.makedirs(cache_path)  # make the folder in the cache

        if os.path.isdir(cur_dir):
            os.rmdir(cur_dir)  # if the target exists remove it

        print cache_path, cur_dir

        os.symlink(cache_path, cur_dir)

        # copy fit dirs
    fit_file = os.path.join(base_dir, "fit.inp")
    if os.path.isfile(fit_file):
        fit_array = inp_get_token_array(fit_file, "#fitnames")
        do_fit = inp_get_token_array(fit_file, "#do_fit")
        if (int(fit_array[0]) > 0) and (do_fit == 1):
            exp_dir = os.path.join(cur_dir, "exp")
            if not os.path.exists(exp_dir):
                os.makedirs(exp_dir)

            for i in range(1, len(fit_array)):
                shutil.copytree(os.path.join(base_dir, "exp", fit_array[i]), os.path.join(exp_dir, fit_array[i]))

    f_list = glob.iglob(os.path.join(base_dir, "*.inp"))
    for inpfile in f_list:
        shutil.copy(inpfile, cur_dir)

    shutil.copy(os.path.join(base_dir, "sim.opvdm"), cur_dir)
コード例 #2
0
ファイル: ref.py プロジェクト: roderickmackenzie/gpvdm
	def load(self):
		ret=inp_get_token_array(self.file_name, self.token)
		if ret!=False:									#We have found the file and got the token
			self.ui.text.setText("\n".join(ret))
		else:	
			self.ui.text.setText(_("New file"))

			if inp_check_ver(self.file_name, "1.0")==True:	#The file exists but there is no token.
				lines=[]
				inp_load_file(lines,self.file_name)
				lines=inp_add_token(lines,self.token,self.ui.text.toPlainText())
				print("written to 1",self.file_name)
				inp_save_lines(self.file_name,lines)
			else:											#The file does not exist or there is an error
				lines=inp_new_file()
				lines=inp_add_token(lines,self.token,self.ui.text.toPlainText())
				print("written to 2",self.file_name,lines)
				inp_save_lines(self.file_name,lines)
コード例 #3
0
    def load(self):
        ret = inp_get_token_array(self.file_name, self.token)
        if ret != False:  #We have found the file and got the token
            self.ui.text.setText("\n".join(ret))
        else:
            self.ui.text.setText(_("New file"))

            if inp_check_ver(
                    self.file_name,
                    "1.0") == True:  #The file exists but there is no token.
                lines = []
                lines = inp_load_file(self.file_name)
                lines = inp_add_token(lines, self.token,
                                      self.ui.text.toPlainText())
                print("written to 1", self.file_name)
                inp_save_lines_to_file(self.file_name, lines)
            else:  #The file does not exist or there is an error
                lines = inp_new_file()
                lines = inp_add_token(lines, self.token,
                                      self.ui.text.toPlainText())
                print("written to 2", self.file_name, lines)
                inp_save_lines_to_file(self.file_name, lines)