def load_sim(self, filename): new_path = os.path.dirname(filename) if filename.startswith(get_share_path()) == True: error_dlg( self, _("You should not try to open simulations in the root gpvdm directory." )) return if ver_check_compatibility(filename) == True: self.change_dir_and_refresh_interface(new_path) else: update = yes_no_dlg( self, _("The simulation you want to import looks like it was made on an old version of gpvdm, do you want to try to open it anyway?" )) if update == True: update_simulaton_to_new_ver(filename) self.change_dir_and_refresh_interface(new_path) if os.path.isdir(os.path.join(new_path, "materials")) == False: copy = yes_no_dlg( self, _("It looks like there is no materials database in the simulation directory should I import one?" )) if copy == True: clone_materials(new_path)
def update_fetch(): text=[] text.append("Checking web for updates...") # disk_files=[] web_src=[] disk_dest=[] update_path="http://www.gpvdm.com/update_windows/"+ver()+"/" lines=get_data_from_web(update_path+"list.dat") print("Got file list") lines=lines.split('\n') files=[] md5=[] web_md5=[] for i in range(0,len(lines)): if lines[i].count(" ")!=0: m,f=lines[i].split(" ") f=f[2:].split("/") md5.append(m) files.append(f) for i in range(0,len(files)): root=files[i][0] if root=="images" or root=="solvers" or root=="gpvdm_core.exe" or root=="device_lib" or root=="sim.gpvdm" or root=="lang" or root=="materials" or root=="light": md5_web=md5[i] md5_disk="none" disk_path=os.path.join(get_share_path(),"/".join(files[i])) web_path=update_path+"/".join(files[i]) if os.path.isfile(disk_path): md5_disk=hashlib.md5(open(disk_path,'rb').read()).hexdigest() if md5_web!=md5_disk: web_src.append(web_path) disk_dest.append(disk_path) web_md5.append(md5_web) for i in range(0,len(web_src)): text.append(web_src[i]+" "+disk_dest[i]) a=get_data_from_web(web_src[i]) l=len(a) if l>100: l=100; if a[:l].count("403 Forbidden")!=0: text.append("Access to file "+web_src[i]+" forbidden") else: web_hash=hashlib.md5(a).hexdigest() list_hash=web_md5[i] if web_hash==list_hash: text.append("updating file "+disk_dest[i]) if running_on_linux()==False: f=open(disk_dest[i], mode='wb') lines = f.write(a) f.close() else: text.append("Checksum error "+disk_dest[i]) return text
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_share_path(), "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() langs = get_languages() self.lang_box.addItem("auto") for i in range(0, len(langs)): self.lang_box.addItem(langs[i]) token = inp_get_token_value(self.file_path, "#lang", archive="base.gpvdm") 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) 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)
def advanced_features(): if os.path.isdir(os.path.join(get_share_path(),"advanced"))==True: return True else: return False
def debug_mode(): if os.path.isfile(os.path.join(get_share_path(),"debug_mode"))==True: return True else: return False
def ver_load_info(): lines=[] global core global ver_error global subver core="" ver_error="" ver_file_path=os.path.join(get_inp_file_path(),"ver.inp") lines=inp_load_file(ver_file_path,archive="base.gpvdm") if lines!=False: core=inp_search_token_value(lines,"#core") subver=inp_search_token_value(lines,"#sub_ver") return True else: ver_error="I can not find the file sim.gpvdm/ver.inp.\n\nI have tried looking in "+ver_file_path+"\n\nThe share path is"+get_share_path()+"\n\nThe bin path is"+get_bin_path()+"\n\nThe current working dir is "+get_sim_path()+"\n\nTry reinstalling a new version of gpvdm and/or report the bug to me at [email protected]." return False
def ver_load_info(): lines=[] global core global mat global ver_error core="" mat="" ver_error="" ver_file_path=os.path.join(get_inp_file_path(),"ver.inp") if inp_load_file(lines,ver_file_path)==True: core=lines[1] mat=lines[5] return True else: ver_error="I can not find the file sim.gpvdm/ver.inp.\n\nI have tried looking in "+ver_file_path+"\n\nThe share path is"+get_share_path()+"\n\nThe bin path is"+get_bin_path()+"\n\nThe current working dir is "+os.getcwd()+"\n\nTry reinstalling a new version of gpvdm and/or report the bug to me at [email protected]." return False