Exemple #1
0
def uid_get():
    uid = ""
    if running_on_linux() == True:
        path = os.path.join(expanduser("~"), ".gpvdm_uid.inp")
    else:
        path = os.path.join(get_exe_path(), "uid.inp")

    try:
        lines = []
        found = False

        lines = inp_load_file(path)
        if lines != False:
            uid = inp_search_token_value(lines, "#uid")
            found = True

        if found == False:
            uid = str(uuid.uuid4())[0:8]
            lines = []
            lines.append("#uid")
            lines.append(uid)
            lines.append("#ver")
            lines.append("1.0")
            lines.append("#end")

            inp_save(path, lines)
    except:
        print("uid error")

    return uid
def check_lib_in_bash_rc():
    if running_on_linux() == True:
        f = inp()
        gpvdm_installed = -1
        if f.load(os.path.join(get_home_path(), ".bashrc")) != False:
            for i in range(0, len(f.lines)):
                if f.lines[i].startswith(
                        "export LD_LIBRARY_PATH"
                ) == True and f.lines[i].count("gpvdm") != 0:
                    gpvdm_installed = i
                    if f.lines[i].endswith(get_exe_path()):
                        return
        line = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:" + get_exe_path()

        if gpvdm_installed == -1:
            f.lines.append(line)
        else:
            f.lines[i] = line
        f.save()
Exemple #3
0
    def callback_next(self):
        help_window().help_set_help([
            "document-save-as.png",
            _("<big><b>Now save the simulation</b></big><br>Now select where you would like to save the simulation directory."
              )
        ])

        if len(self.viewer.selectedItems()) > 0:

            password = inp_get_token_value("info.inp",
                                           "#info_password",
                                           archive=self.viewer.file_path)
            if password != "":
                pw_dlg = dlg_get_text(_("password:"******"", "document-new")
                if password != pw_dlg.ret:
                    return

            file_path = save_as_gpvdm(self)
            #print(file_path,get_exe_path())
            if file_path != None:
                if file_path.startswith(get_exe_path()) == True:
                    error_dlg(
                        self,
                        _("It's not a good idea to save the simulation in the gpvdm installation directory."
                          ))
                    return

                if os.path.isdir(file_path) == True:
                    error_dlg(
                        self,
                        _("That directory already exists.  Pick another name or delete the old one."
                          ))
                    return

                if not os.path.exists(file_path):
                    os.makedirs(file_path)

                self.ret_path = file_path
                os.chdir(self.ret_path)
                bugs_clear()
                bugs_add_action(os.path.basename(self.viewer.file_path))
                gpvdm_clone(os.getcwd(), copy_dirs=True)
                import_archive(self.viewer.file_path,
                               os.path.join(os.getcwd(), "sim.gpvdm"), False)
                self.close()
        else:
            error_dlg(self, _("Please select a device before clicking next"))
Exemple #4
0
    def callback_next(self):
        help_window().help_set_help([
            "document-save-as.png",
            _("<big><b>Now save the simulation</b></big><br>Now select where you would like to save the simulation directory."
              )
        ])

        if len(self.viewer.selectedItems()) > 0:

            password = inp_get_token_value("info.inp",
                                           "#info_password",
                                           archive=self.viewer.file_path)
            if password != "":
                pw_dlg = dlg_get_text(_("password:"******"",
                                      "gnome-dialog-password")
                if password != pw_dlg.ret:
                    error_dlg(self, _("Wrong password"))
                    return

            file_path = save_as_gpvdm(self)
            #print(file_path,get_exe_path())
            if file_path != None:
                if file_path.startswith(get_exe_path()) == True:
                    error_dlg(
                        self,
                        _("It's not a good idea to save the simulation in the gpvdm installation directory.  Try saving it somewhere else, such as your desktop or home directory."
                          ))
                    return

                if os.path.isdir(file_path) == True:
                    error_dlg(
                        self,
                        _("That directory already exists.  Pick another name or delete the old one."
                          ))
                    return

                if not os.path.exists(file_path):
                    os.makedirs(file_path)

                self.ret_path = file_path

                os.chdir(self.ret_path)
                bugs_clear()
                bugs_add_action(os.path.basename(self.viewer.file_path))
                gpvdm_clone(os.getcwd(), copy_dirs=True)
                import_archive(self.viewer.file_path,
                               os.path.join(os.getcwd(), "sim.gpvdm"), False)

                disk_speed = disk_test(file_path)
                print("disk_speed=", file_path, disk_speed)

                inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                       "#dump_optics_verbose", "false")
                inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                       "#dump_print_newtonerror", "false")

                if disk_speed < 15000:
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#newton_dump", "false")
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#dump_energy_slice_switch",
                                           "false")
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#dump_write_converge", "false")
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#dump_first_guess", "false")

                if disk_speed < 10000:
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#dump_workbook", "false")
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#dump_file_access_log", "false")
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#dump_write_out_band_structure",
                                           "false")
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#dump_1d_slices", "false")

                if disk_speed < 1000:
                    inp_update_token_value(os.path.join(file_path, "dump.inp"),
                                           "#dump_log_level", "screen")

                self.close()
        else:
            error_dlg(self, _("Please select a device before clicking next"))