Exemplo n.º 1
0
    def load_config(self):
        self.cache_config_file = os.path.join(get_user_settings_dir(),
                                              "cache.inp")
        self.max_size = 1000
        self.enabled = True
        if os.path.isfile(self.cache_config_file) == False:
            speed = disk_test(get_user_settings_dir())
            lines = []
            lines.append("#cache_size")
            lines.append(str(self.max_size))
            lines.append("#cache_disk_speed")
            lines.append(str(speed))
            if (speed < 200):
                self.enabled = False
            lines.append("#cache_enabled")
            lines.append(str(self.enabled))
            lines.append("#ver")
            lines.append("1.0")
            lines.append("#end")

            inp_save_lines_to_file(self.cache_config_file, lines)

        else:
            lines = inp_load_file(
                os.path.join(get_user_settings_dir(), "cache.inp"))
            self.max_size = int(inp_search_token_value(lines, "#cache_size"))
            self.enabled = str2bool(
                inp_search_token_value(lines, "#cache_enabled"))
Exemplo n.º 2
0
def wpos_load():
    #print("load")
    global wlist
    wlist = []
    lines = []
    pos = 0
    lines = inp_load_file(
        os.path.join(get_user_settings_dir(), "window_list.inp"))

    if lines == False:
        return

    if len(lines) < 2:
        return

    while (1):
        token, name, pos = inp_read_next_item(lines, pos)
        if token == "#end" or token == "#ver":
            break

        token, x, pos = inp_read_next_item(lines, pos)

        token, y, pos = inp_read_next_item(lines, pos)

        a = window_item()
        a.name = name
        a.x = float(x)
        a.y = float(y)
        wlist.append(a)
Exemplo n.º 3
0
def write_lang_config_file():
    lines = []
    lines.append("#lang")
    lines.append("auto")
    lines.append("#ver")
    lines.append("1.0")
    lines.append("#end")
    inp_save(os.path.join(get_user_settings_dir(), "lang.inp"), lines)
Exemplo n.º 4
0
def used_files_add(file_name):
    files = used_files_load()
    path = os.path.join(get_user_settings_dir(), "used_files.inp")
    if file_name in files:
        return
    files.insert(0, file_name)
    if len(files) > 10:
        files = files[:10]

    inp_save_lines_to_file(path, files)
Exemplo n.º 5
0
    def __init__(self):
        QScrollArea.__init__(self)
        self.vbox = QVBoxLayout()

        self.tab = QHBoxLayout()
        widget = QWidget()
        widget.setLayout(self.tab)
        self.file_path = os.path.join(get_user_settings_dir(), "lang.inp")

        title_label = QLabel()
        title_label.setWordWrap(True)
        title_label.setOpenExternalLinks(True)
        title_label.setText(
            latex_to_html(
                "<font size=5><b>Select the language you would like use gpvdm to use.</b><br><br> If a translation to your language does not exist or could be improved, then please consider joining the <a href=\"https://gpvdm.com/translation.html\">gpvdm translation project</a>.  I would like gpvdm translated into as many langauges as possible to improve access to high quality solar cell simulation tools for all.</font>"
            ))

        self.vbox.addWidget(title_label)
        self.vbox.addWidget(widget)

        description = QLabel()
        description.setText(latex_to_html("Default language:"))

        self.lang_box = QComboBox()

        self.lang_box.addItem("auto")

        self.lang_box.setFixedSize(300, 25)

        self.tab.addWidget(description)
        self.tab.addWidget(self.lang_box)

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vbox.addWidget(spacer)
        self.setLayout(self.vbox)

        langs = get_languages()
        if langs == False:
            return

        for i in range(0, len(langs)):
            self.lang_box.addItem(langs[i])

        token = inp_get_token_value(self.file_path, "#lang")
        all_items = [
            self.lang_box.itemText(i) for i in range(self.lang_box.count())
        ]
        for i in range(0, len(all_items)):
            if all_items[i] == token:
                self.lang_box.setCurrentIndex(i)

        self.lang_box.currentIndexChanged.connect(self.callback_edit)
Exemplo n.º 6
0
	def load_new(self):
		if self.get_reg_key("new_install")=="true":
			print("fresh install.....")
			return False

		lines=[]

		if os.path.isfile(os.path.join(get_user_settings_dir(),"settings.inp"))==False:
			return False

		lines=lock_load(self.data_path)
#		print(lines)

		self.reg_client_ver=self.get_reg_key("ver")
		if self.reg_client_ver==False:
			self.reg_client_ver="linux"

		if lines==False:
			return False

		ver=inp_search_token_value(lines, "#ver")
		if ver=="2.0":
			return False

		self.uid=inp_search_token_value(lines, "#uid")
		self.use_count=int(inp_search_token_value(lines, "#use_count"))
		self.locked=inp_search_token_value(lines, "#locked").split(";")
		self.not_locked=inp_search_token_value(lines, "#not_locked").split(";")

		self.update_available=str2bool(inp_search_token_value(lines, "#update_available"))

		self.client_ver_from_lock=inp_search_token_value(lines, "#client_ver")

		self.status=inp_search_token_value(lines, "#status")
		self.my_email=inp_search_token_value(lines, "#my_email")
		self.question=inp_search_token_value(lines, "#question")

		ver=float(inp_search_token_value(lines, "#ver"))

		if ver>1.0:
			self.registered=True
			return True

		return False
		return True
Exemplo n.º 7
0
def wpos_save():
    global wlist
    lines = []

    for i in range(0, len(wlist)):
        lines.append("#window_name_" + wlist[i].name)
        lines.append(wlist[i].name)
        lines.append("#window_x_" + wlist[i].name)
        lines.append(str(wlist[i].x))
        lines.append("#window_y_" + wlist[i].name)
        lines.append(str(wlist[i].y))

    lines.append("#ver")
    lines.append("1.0")
    lines.append("#end")

    ret = inp_save(os.path.join(get_user_settings_dir(), "window_list.inp"),
                   lines)
    return ret
Exemplo n.º 8
0
	def __init__(self):
		self.registered=False

		self.uid=""
		self.error=""
		self.open_gl_working=True
		self.reg_client_ver="ver"
		self.client_ver_from_lock=""
		self.status="no_key"
		self.locked=[]
		self.not_locked=[]
		self.update_available=False
		self.website="www.gpvdm.com"
		self.port="/api"
		self.my_email=""
		self.question="Questions? Contact: "
		self.data_path=os.path.join(get_user_settings_dir(),"info.inp")

		if self.load()==True:
			if self.client_ver_from_lock!=self.reg_client_ver:
				self.get_license()
Exemplo n.º 9
0
 def callback_clear_cache(self):
     path = os.path.join(get_user_settings_dir(), "cache")
     gpvdm_delete_file(path)
     self.close()
Exemplo n.º 10
0
def used_files_load():
    path = os.path.join(get_user_settings_dir(), "used_files.inp")
    if os.path.isfile(path) == True:
        lines = read_lines_from_file(path)
        return lines
    return []
Exemplo n.º 11
0
from inp import inp_save

locale_path = get_lang_path()


def write_lang_config_file():
    lines = []
    lines.append("#lang")
    lines.append("auto")
    lines.append("#ver")
    lines.append("1.0")
    lines.append("#end")
    inp_save(os.path.join(get_user_settings_dir(), "lang.inp"), lines)


config_path = os.path.join(get_user_settings_dir(), "lang.inp")
file_lang = inp_get_token_value(config_path, "#lang", archive="base.gpvdm")
if file_lang == None:
    file_lang = "auto"
    write_lang_config_file()

if file_lang == "auto":
    current_locale, encoding = locale.getdefaultlocale()
    if current_locale == None:
        print("No local language set assuming en_US")
        current_locale = "en_US"
else:
    current_locale = file_lang
language = gettext.translation('gpvdm',
                               locale_path, [current_locale],
                               fallback=True)