예제 #1
0
    def on_browse_button(self, extended=False):
        default_dir = FSGSDirectories.get_kickstarts_dir()
        if extended:
            title = gettext("Choose Extended ROM")
            key = "kickstart_ext_file"
        else:
            title = gettext("Choose Kickstart ROM")
            key = "kickstart_file"
        dialog = LauncherFilePicker(self.get_window(), title, "rom",
                                    LauncherConfig.get(key))
        if not dialog.show_modal():
            return
        path = dialog.get_path()

        checksum_tool = ChecksumTool(self.get_window())
        sha1 = checksum_tool.checksum_rom(path)

        dir_path, file = os.path.split(path)
        if extended:
            self.ext_text_field.set_text(file)
        else:
            self.text_field.set_text(file)
        if os.path.normcase(os.path.normpath(dir_path)) == \
                os.path.normcase(os.path.normpath(default_dir)):
            path = file

        if extended:
            LauncherConfig.set_multiple([("kickstart_ext_file", path),
                                         ("x_kickstart_ext_file", path),
                                         ("x_kickstart_ext_file_sha1", sha1)])
        else:
            LauncherConfig.set_multiple([("kickstart_file", path),
                                         ("x_kickstart_file", path),
                                         ("x_kickstart_file_sha1", sha1)])
예제 #2
0
    def browse(self, dir_mode):
        default_dir = FSGSDirectories.get_hard_drives_dir()
        dialog = LauncherFilePicker(
            self.get_window(),
            gettext("Choose Hard Drive"),
            "hd",
            LauncherConfig.get(self.config_key),
            dir_mode=dir_mode,
        )
        if not dialog.show_modal():
            dialog.destroy()
            return
        path = dialog.get_path()
        dialog.destroy()

        checksum_tool = ChecksumTool(self.get_window())
        sha1 = ""
        if dir_mode:
            print("not calculating HD checksums for directories")
        else:
            size = os.path.getsize(path)
            if size < 64 * 1024 * 1024:
                sha1 = checksum_tool.checksum(path)
            else:
                print("not calculating HD checksums HD files > 64MB")
        full_path = path

        # FIXME: use contract function
        dir_path, file = os.path.split(path)
        self.text_field.set_text(file)
        if os.path.normcase(os.path.normpath(dir_path)) == os.path.normcase(
            os.path.normpath(default_dir)
        ):
            path = file

        self.text_field.set_text(path)
        values = [(self.config_key, path), (self.config_key_sha1, sha1)]
        if self.index == 0:
            # whdload_args = ""
            # dummy, ext = os.path.splitext(path)
            # if not dir_mode and ext.lower() in Archive.extensions:
            #     try:
            #         whdload_args = self.calculate_whdload_args(full_path)
            #     except Exception:
            #         traceback.print_exc()
            # values.append(("x_whdload_args", whdload_args))
            values.extend(
                whdload.generate_config_for_archive(
                    full_path, model_config=False
                ).items()
            )
        LauncherConfig.set_multiple(values)
예제 #3
0
    def browse(self, dir_mode):
        default_dir = FSGSDirectories.get_hard_drives_dir()
        dialog = LauncherFilePicker(
            self.get_window(),
            gettext("Choose Hard Drive"),
            "hd",
            LauncherConfig.get(self.config_key),
            dir_mode=dir_mode,
        )
        if not dialog.show_modal():
            dialog.destroy()
            return
        path = dialog.get_path()
        dialog.destroy()

        checksum_tool = ChecksumTool(self.get_window())
        sha1 = ""
        if dir_mode:
            print("not calculating HD checksums for directories")
        else:
            size = os.path.getsize(path)
            if size < 64 * 1024 * 1024:
                sha1 = checksum_tool.checksum(path)
            else:
                print("not calculating HD checksums HD files > 64MB")
        full_path = path

        # FIXME: use contract function
        dir_path, file = os.path.split(path)
        self.text_field.set_text(file)
        if os.path.normcase(os.path.normpath(dir_path)) == os.path.normcase(
                os.path.normpath(default_dir)):
            path = file

        self.text_field.set_text(path)
        values = [(self.config_key, path), (self.config_key_sha1, sha1)]
        if self.index == 0:
            # whdload_args = ""
            # dummy, ext = os.path.splitext(path)
            # if not dir_mode and ext.lower() in Archive.extensions:
            #     try:
            #         whdload_args = self.calculate_whdload_args(full_path)
            #     except Exception:
            #         traceback.print_exc()
            # values.append(("x_whdload_args", whdload_args))
            values.extend(
                whdload.generate_config_for_archive(
                    full_path, model_config=False).items())
        LauncherConfig.set_multiple(values)
예제 #4
0
 def set_new_config(self, items):
     if self.cd_mode:
         max_items = Amiga.MAX_CDROM_IMAGES
     else:
         max_items = Amiga.MAX_FLOPPY_IMAGES
     set_list = []
     for i in range(max(max_items, len(items))):
         if i >= max_items:
             break
         elif i >= len(items):
             path, sha1 = "", ""
         else:
             path, sha1 = items[i]
         set_list.append((self.file_key.format(i), path))
         set_list.append((self.sha1_key.format(i), sha1))
     LauncherConfig.set_multiple(set_list)
예제 #5
0
 def set_new_config(self, items):
     if self.cd_mode:
         max_items = Amiga.MAX_CDROM_IMAGES
     else:
         max_items = Amiga.MAX_FLOPPY_IMAGES
     set_list = []
     for i in range(max(max_items, len(items))):
         if i >= max_items:
             break
         elif i >= len(items):
             path, sha1 = "", ""
         else:
             path, sha1 = items[i]
         set_list.append((self.file_key.format(i), path))
         set_list.append((self.sha1_key.format(i), sha1))
     LauncherConfig.set_multiple(set_list)
예제 #6
0
    def on_browse_button(self, extended=False):
        default_dir = FSGSDirectories.get_kickstarts_dir()
        if extended:
            title = gettext("Choose Extended ROM")
            key = "kickstart_ext_file"
        else:
            title = gettext("Choose Kickstart ROM")
            key = "kickstart_file"
        dialog = LauncherFilePicker(
            self.get_window(), title, "rom", LauncherConfig.get(key)
        )
        if not dialog.show_modal():
            return
        path = dialog.get_path()

        checksum_tool = ChecksumTool(self.get_window())
        sha1 = checksum_tool.checksum_rom(path)

        dir_path, file = os.path.split(path)
        if extended:
            self.ext_text_field.set_text(file)
        else:
            self.text_field.set_text(file)
        if os.path.normcase(os.path.normpath(dir_path)) == os.path.normcase(
            os.path.normpath(default_dir)
        ):
            path = file

        if extended:
            LauncherConfig.set_multiple(
                [
                    ("kickstart_ext_file", path),
                    ("x_kickstart_ext_file", path),
                    ("x_kickstart_ext_file_sha1", sha1),
                ]
            )
        else:
            LauncherConfig.set_multiple(
                [
                    ("kickstart_file", path),
                    ("x_kickstart_file", path),
                    ("x_kickstart_file_sha1", sha1),
                ]
            )
예제 #7
0
 def update_config(self):
     text = self.text_area.get_text()
     update_config = {}
     # First mark all unknown config values as cleared
     for key in list(fsgs.config.values.keys()):
         if key not in LauncherConfig.default_config:
             update_config[key] = ""
     # Then we overwrite with specific values
     for line in text.split("\n"):
         line = line.strip()
         parts = line.split("=", 1)
         if len(parts) == 2:
             key = parts[0].strip()
             # if key in Config.no_custom_config:
             #     continue
             value = parts[1].strip()
             update_config[key] = value
     # Finally, set everything at once
     LauncherConfig.set_multiple(update_config.items())
예제 #8
0
 def update_config(self):
     text = self.text_area.get_text()
     update_config = {}
     # First mark all unknown config values as cleared
     for key in list(fsgs.config.values.keys()):
         if key not in LauncherConfig.default_config:
             update_config[key] = ""
     # Then we overwrite with specific values
     for line in text.split("\n"):
         line = line.strip()
         parts = line.split("=", 1)
         if len(parts) == 2:
             key = parts[0].strip()
             # if key in Config.no_custom_config:
             #     continue
             value = parts[1].strip()
             update_config[key] = value
     # Finally, set everything at once
     LauncherConfig.set_multiple(update_config.items())
예제 #9
0
    def multi_select(cls, parent=None):
        default_dir = FSGSDirectories.get_cdroms_dir()
        dialog = LauncherFilePicker(
            parent, gettext("Select Multiple CD-ROMs"), "cd", multiple=True
        )

        if not dialog.show_modal():
            return
        paths = dialog.get_paths()
        paths.sort()

        # checksum_tool = ChecksumTool(parent)
        for i, path in enumerate(paths):
            # sha1 = checksum_tool.checksum(path)
            sha1 = ""
            print("FIXME: not calculating CD checksum just yet")
            path = Paths.contract_path(path, default_dir)

            if i < 1:
                LauncherConfig.set_multiple(
                    [
                        ("cdrom_drive_{0}".format(i), path),
                        ("x_cdrom_drive_{0}_sha1".format(i), sha1),
                    ]
                )
            LauncherConfig.set_multiple(
                [
                    ("cdrom_image_{0}".format(i), path),
                    ("x_cdrom_image_{0}_sha1".format(i), sha1),
                ]
            )

        # blank the rest of the drives
        for i in range(len(paths), 1):
            LauncherConfig.set_multiple(
                [
                    ("cdrom_drive_{0}".format(i), ""),
                    ("x_cdrom_drive_{0}_sha1".format(i), ""),
                ]
            )

            # Config.set("x_cdrom_drive_{0}_sha1".format(i), "")
            # Config.set("x_cdrom_drive_{0}_name".format(i), "")
        # blank the rest of the image list
        for i in range(len(paths), Amiga.MAX_CDROM_IMAGES):
            LauncherConfig.set_multiple(
                [
                    ("cdrom_image_{0}".format(i), ""),
                    ("x_cdrom_image_{0}_sha1".format(i), ""),
                ]
            )
 def do_update(self):
     if not self.dirty:
         return
     self.dirty = False
     # print("ImplicitConfigHandler.do_update")
     implicit = ImplicitConfig(ConfigProxy(get_config(self.parent())),
                               SettingsProxy())
     # failed = False
     try:
         expand_config(implicit, ExpandFunctions())
     except Exception:
         traceback.print_exc()
         print("expand_config failed")
         # failed = True
     implicit_config = {
         key: ""
         for key in LauncherConfig.keys() if key.startswith("__implicit_")
     }
     for key, value in implicit.items():
         implicit_config["__implicit_" + key] = value
     LauncherConfig.set_multiple(list(implicit_config.items()))
    def do_update(self):
        if not self.dirty:
            return
        self.dirty = False
        print("ImplicitConfigHandler.do_update")
        implicit = ImplicitConfig(ConfigProxy(), SettingsProxy())
        # failed = False
        try:
            expand_config(implicit, ExpandFunctions())
        except Exception:
            traceback.print_exc()
            print("expand_config failed")
            # failed = True
        implicit_config = {
            key: "" for key in LauncherConfig.keys()
            if key.startswith("__implicit_")}
        for key, value in implicit.items():
            implicit_config["__implicit_" + key] = value
        LauncherConfig.set_multiple(list(implicit_config.items()))

        if self.parent().config_browser:
            self.parent().config_browser.update_from_implicit(implicit)
예제 #12
0
    def multi_select(cls, parent=None):
        default_dir = FSGSDirectories.get_cdroms_dir()
        dialog = LauncherFilePicker(parent,
                                    gettext("Select Multiple CD-ROMs"),
                                    "cd",
                                    multiple=True)

        if not dialog.show_modal():
            return
        paths = dialog.get_paths()
        paths.sort()

        # checksum_tool = ChecksumTool(parent)
        for i, path in enumerate(paths):
            # sha1 = checksum_tool.checksum(path)
            sha1 = ""
            print("FIXME: not calculating CD checksum just yet")
            path = Paths.contract_path(path, default_dir)

            if i < 1:
                LauncherConfig.set_multiple([
                    ("cdrom_drive_{0}".format(i), path),
                    ("x_cdrom_drive_{0}_sha1".format(i), sha1),
                ])
            LauncherConfig.set_multiple([
                ("cdrom_image_{0}".format(i), path),
                ("x_cdrom_image_{0}_sha1".format(i), sha1),
            ])

        # blank the rest of the drives
        for i in range(len(paths), 1):
            LauncherConfig.set_multiple([
                ("cdrom_drive_{0}".format(i), ""),
                ("x_cdrom_drive_{0}_sha1".format(i), ""),
            ])

            # Config.set("x_cdrom_drive_{0}_sha1".format(i), "")
            # Config.set("x_cdrom_drive_{0}_name".format(i), "")
        # blank the rest of the image list
        for i in range(len(paths), Amiga.MAX_CDROM_IMAGES):
            LauncherConfig.set_multiple([
                ("cdrom_image_{0}".format(i), ""),
                ("x_cdrom_image_{0}_sha1".format(i), ""),
            ])
예제 #13
0
 def on_eject_button(self):
     LauncherConfig.set_multiple([(self.config_key, ""),
                                  (self.config_key_sha1, "")])
예제 #14
0
 def on_eject_button(self):
     LauncherConfig.set_multiple(
         [(self.config_key, ""), (self.config_key_sha1, "")]
     )
예제 #15
0
 def clear_cdrom_list(cls):
     values = []
     for i in range(Amiga.MAX_CDROM_IMAGES):
         values.append(("cdrom_image_{0}".format(i), ""))
         values.append(("x_cdrom_image_{0}_sha1".format(i), ""))
     LauncherConfig.set_multiple(values)
예제 #16
0
 def eject(cls, drive):
     values = [
         ("cdrom_drive_{0}".format(drive), ""),
         ("x_cdrom_drive_{0}_sha1".format(drive), ""),
     ]
     LauncherConfig.set_multiple(values)
예제 #17
0
 def clear_cdrom_list(cls):
     values = []
     for i in range(Amiga.MAX_CDROM_IMAGES):
         values.append(("cdrom_image_{0}".format(i), ""))
         values.append(("x_cdrom_image_{0}_sha1".format(i), ""))
     LauncherConfig.set_multiple(values)
예제 #18
0
 def eject(cls, drive):
     values = [("cdrom_drive_{0}".format(drive), ""),
               ("x_cdrom_drive_{0}_sha1".format(drive), "")]
     LauncherConfig.set_multiple(values)