Exemplo n.º 1
0
    def prelaunch(self):
        config_file = self.get_config_file()
        if not os.path.exists(config_file):
            logger.warning(
                "Unable to find retroarch config. Except erratic behavior")
            return True
        retro_config = RetroConfig(config_file)

        retro_config['libretro_directory'] = get_default_cores_directory()
        retro_config['libretro_info_path'] = get_default_info_directory()

        # Change assets path to the Lutris provided one if necessary
        assets_directory = os.path.expanduser(retro_config['assets_directory'])
        if system.path_is_empty(assets_directory):
            retro_config['assets_directory'] = get_default_assets_directory()
        retro_config.save()

        core = self.game_config.get('core')
        info_file = os.path.join(get_default_info_directory(),
                                 '{}_libretro.info'.format(core))
        if os.path.exists(info_file):
            core_config = RetroConfig(info_file)
            try:
                firmware_count = int(core_config['firmware_count'])
            except (ValueError, TypeError):
                firmware_count = 0
            system_path = self.get_system_directory(retro_config)
            notes = core_config['notes'] or ''
            checksums = {}
            if notes.startswith('Suggested md5sums:'):
                parts = notes.split('|')
                for part in parts[1:]:
                    checksum, filename = part.split(' = ')
                    checksums[filename] = checksum
            for index in range(firmware_count):
                firmware_filename = core_config['firmware%d_path' % index]
                firmware_path = os.path.join(system_path, firmware_filename)
                if os.path.exists(firmware_path):
                    if firmware_filename in checksums:
                        checksum = system.get_md5_hash(firmware_path)
                        if checksum == checksums[firmware_filename]:
                            checksum_status = 'Checksum good'
                        else:
                            checksum_status = 'Checksum failed'
                    else:
                        checksum_status = 'No checksum info'
                    logger.info("Firmware '{}' found ({})".format(
                        firmware_filename, checksum_status))
                else:
                    logger.warning(
                        "Firmware '{}' not found!".format(firmware_filename))

                # Before closing issue #431
                # TODO check for firmware*_opt and display an error message if
                # firmware is missing
                # TODO Add dialog for copying the firmware in the correct
                # location

        return True
Exemplo n.º 2
0
    def prelaunch(self):
        config_file = self.get_config_file()
        if not os.path.exists(config_file):
            logger.warning("Unable to find retroarch config. Except erratic behavior")
            return True
        retro_config = RetroConfig(config_file)

        retro_config['libretro_directory'] = get_default_cores_directory()
        retro_config['libretro_info_path'] = get_default_info_directory()

        # Change assets path to the Lutris provided one if necessary
        assets_directory = os.path.expanduser(retro_config['assets_directory'])
        if system.path_is_empty(assets_directory):
            retro_config['assets_directory'] = get_default_assets_directory()
        retro_config.save()

        core = self.game_config.get('core')
        info_file = os.path.join(get_default_info_directory(),
                                 '{}_libretro.info'.format(core))
        if os.path.exists(info_file):
            core_config = RetroConfig(info_file)
            try:
                firmware_count = int(core_config['firmware_count'])
            except (ValueError, TypeError):
                firmware_count = 0
            system_path = self.get_system_directory(retro_config)
            notes = core_config['notes'] or ''
            checksums = {}
            if notes.startswith('Suggested md5sums:'):
                parts = notes.split('|')
                for part in parts[1:]:
                    checksum, filename = part.split(' = ')
                    checksums[filename] = checksum
            for index in range(firmware_count):
                firmware_filename = core_config['firmware%d_path' % index]
                firmware_path = os.path.join(system_path, firmware_filename)
                if os.path.exists(firmware_path):
                    if firmware_filename in checksums:
                        checksum = system.get_md5_hash(firmware_path)
                        if checksum == checksums[firmware_filename]:
                            checksum_status = 'Checksum good'
                        else:
                            checksum_status = 'Checksum failed'
                    else:
                        checksum_status = 'No checksum info'
                    logger.info("Firmware '{}' found ({})".format(firmware_filename,
                                                                  checksum_status))
                else:
                    logger.warning("Firmware '{}' not found!".format(firmware_filename))

                # Before closing issue #431
                # TODO check for firmware*_opt and display an error message if
                # firmware is missing
                # TODO Add dialog for copying the firmware in the correct
                # location

        return True
Exemplo n.º 3
0
    def prelaunch(self):
        config_file = self.get_config_file()
        if os.path.exists(config_file):
            retro_config = RetroConfig(config_file)

            retro_config['libretro_directory'] = get_default_cores_directory()
            retro_config['libretro_info_path'] = get_default_info_directory()

            # Change assets path to the Lutris provided one if necessary
            assets_directory = os.path.expanduser(retro_config['assets_directory'])
            if system.path_is_empty(assets_directory):
                retro_config['assets_directory'] = get_default_assets_directory()
            retro_config.save()
        return True
Exemplo n.º 4
0
    def prelaunch(self):
        config_file = self.get_config_file()
        if os.path.exists(config_file):
            retro_config = RetroConfig(config_file)

            retro_config['libretro_directory'] = get_default_cores_directory()
            retro_config['libretro_info_path'] = get_default_info_directory()

            # Change assets path to the Lutris provided one if necessary
            assets_directory = os.path.expanduser(
                retro_config['assets_directory'])
            if system.path_is_empty(assets_directory):
                retro_config[
                    'assets_directory'] = get_default_assets_directory()
            retro_config.save()
        return True
Exemplo n.º 5
0
def get_libretro_cores():
    cores = []
    runner_path = get_default_config_path()
    if os.path.exists(runner_path):
        # Get core identifiers from info dir
        info_path = get_default_config_path("info")
        if not os.path.exists(info_path):
            req = requests.get(
                "http://buildbot.libretro.com/assets/frontend/info.zip",
                allow_redirects=True)
            if req.status_code == requests.codes.ok:  # pylint: disable=no-member
                with open(get_default_config_path('info.zip'),
                          'wb') as info_zip:
                    info_zip.write(req.content)
                with ZipFile(get_default_config_path('info.zip'),
                             'r') as info_zip:
                    info_zip.extractall(info_path)
            else:
                logger.error(
                    "Error retrieving libretro info archive from server: %s - %s",
                    req.status_code, req.reason)
                return []
        # Parse info files to fetch display name and platform/system
        for info_file in os.listdir(info_path):
            if "_libretro.info" not in info_file:
                continue
            core_identifier = info_file.replace("_libretro.info", "")
            core_config = RetroConfig(os.path.join(info_path, info_file))
            if "categories" in core_config.keys(
            ) and "Emulator" in core_config["categories"]:
                core_label = core_config["display_name"] or ""
                core_system = core_config["systemname"] or ""
                cores.append((core_label, core_identifier, core_system))
        cores.sort(key=itemgetter(0))
    if not cores:
        logger.warning("No cores found")
    return cores
Exemplo n.º 6
0
    def prelaunch(self):
        config_file = self.get_config_file()

        # Create retroarch.cfg if it doesn't exist.
        if not system.path_exists(config_file):
            f = open(config_file, "w")
            f.write("# Lutris RetroArch Configuration")
            f.close()

            # Build the default config settings.
            retro_config = RetroConfig(config_file)
            retro_config["libretro_directory"] = get_default_config_path(
                "cores")
            retro_config["libretro_info_path"] = get_default_config_path(
                "info")
            retro_config["content_database_path"] = get_default_config_path(
                "database/rdb")
            retro_config["cheat_database_path"] = get_default_config_path(
                "database/cht")
            retro_config["cursor_directory"] = get_default_config_path(
                "database/cursors")
            retro_config["screenshot_directory"] = get_default_config_path(
                "screenshots")
            retro_config[
                "input_remapping_directory"] = get_default_config_path(
                    "remaps")
            retro_config["video_shader_dir"] = get_default_config_path(
                "shaders")
            retro_config["core_assets_directory"] = get_default_config_path(
                "downloads")
            retro_config["thumbnails_directory"] = get_default_config_path(
                "thumbnails")
            retro_config["playlist_directory"] = get_default_config_path(
                "playlists")
            retro_config["joypad_autoconfig_dir"] = get_default_config_path(
                "autoconfig")
            retro_config["rgui_config_directory"] = get_default_config_path(
                "config")
            retro_config["overlay_directory"] = get_default_config_path(
                "overlay")
            retro_config["assets_directory"] = get_default_config_path(
                "assets")
            retro_config.save()
        else:
            retro_config = RetroConfig(config_file)

        core = self.game_config.get("core")
        info_file = os.path.join(get_default_config_path("info"),
                                 "{}_libretro.info".format(core))
        if system.path_exists(info_file):
            core_config = RetroConfig(info_file)
            try:
                firmware_count = int(core_config["firmware_count"])
            except (ValueError, TypeError):
                firmware_count = 0
            system_path = self.get_system_directory(retro_config)
            notes = core_config["notes"] or ""
            checksums = {}
            if notes.startswith("Suggested md5sums:"):
                parts = notes.split("|")
                for part in parts[1:]:
                    checksum, filename = part.split(" = ")
                    checksums[filename] = checksum
            for index in range(firmware_count):
                firmware_filename = core_config["firmware%d_path" % index]
                firmware_path = os.path.join(system_path, firmware_filename)
                if system.path_exists(firmware_path):
                    if firmware_filename in checksums:
                        checksum = system.get_md5_hash(firmware_path)
                        if checksum == checksums[firmware_filename]:
                            checksum_status = "Checksum good"
                        else:
                            checksum_status = "Checksum failed"
                    else:
                        checksum_status = "No checksum info"
                    logger.info("Firmware '%s' found (%s)", firmware_filename,
                                checksum_status)
                else:
                    logger.warning("Firmware '%s' not found!",
                                   firmware_filename)

                # Before closing issue #431
                # TODO check for firmware*_opt and display an error message if
                # firmware is missing
                # TODO Add dialog for copying the firmware in the correct
                # location

        return True
Exemplo n.º 7
0
            allow_redirects=True)
        if req.status_code == requests.codes.ok:
            open(get_default_config_path('info.zip'), 'wb').write(req.content)
            with ZipFile(get_default_config_path('info.zip'), 'r') as info_zip:
                info_zip.extractall(info_path)
        else:
            logger.error(
                "Error retrieving libretro info archive from server: %s - %s",
                req.status_code, req.reason)
    # Parse info files to fetch display name and platform/system
    if os.path.exists(info_path):
        with os.scandir(info_path) as it:
            for entry in it:
                if entry.is_file():
                    core_identifier = entry.name.replace("_libretro.info", "")
                    core_config = RetroConfig(entry)
                    if "categories" in core_config.keys(
                    ) and "Emulator" in core_config["categories"]:
                        core_label = core_config["display_name"] or ""
                        core_system = core_config["systemname"] or ""
                        LIBRETRO_CORES.append(
                            (core_label, core_identifier, core_system))
            LIBRETRO_CORES.sort(key=itemgetter(0))


def get_core_choices():
    return [(core[0], core[1]) for core in LIBRETRO_CORES]


class libretro(Runner):
    human_name = "Libretro"
Exemplo n.º 8
0
    def prelaunch(self):
        config_file = self.get_config_file()

        # Create retroarch.cfg if it doesn't exist.
        if not os.path.exists(config_file):
            f = open(config_file, 'w')
            f.write('# Lutris RetroArch Configuration')
            f.close()

            # Build the default config settings.
            retro_config = RetroConfig(config_file)
            retro_config['libretro_directory'] = get_default_config_path(
                'cores')
            retro_config['libretro_info_path'] = get_default_config_path(
                'info')
            retro_config['content_database_path'] = get_default_config_path(
                'database/rdb')
            retro_config['cheat_database_path'] = get_default_config_path(
                'database/cht')
            retro_config['cursor_directory'] = get_default_config_path(
                'database/cursors')
            retro_config['screenshot_directory'] = get_default_config_path(
                'screenshots')
            retro_config[
                'input_remapping_directory'] = get_default_config_path(
                    'remaps')
            retro_config['video_shader_dir'] = get_default_config_path(
                'shaders')
            retro_config['core_assets_directory'] = get_default_config_path(
                'downloads')
            retro_config['thumbnails_directory'] = get_default_config_path(
                'thumbnails')
            retro_config['playlist_directory'] = get_default_config_path(
                'playlists')
            retro_config['joypad_autoconfig_dir'] = get_default_config_path(
                'autoconfig')
            retro_config['rgui_config_directory'] = get_default_config_path(
                'config')
            retro_config['overlay_directory'] = get_default_config_path(
                'overlay')
            retro_config['assets_directory'] = get_default_config_path(
                'assets')
            retro_config.save()
        else:
            retro_config = RetroConfig(config_file)

        core = self.game_config.get('core')
        info_file = os.path.join(get_default_config_path('info'),
                                 '{}_libretro.info'.format(core))
        if os.path.exists(info_file):
            core_config = RetroConfig(info_file)
            try:
                firmware_count = int(core_config['firmware_count'])
            except (ValueError, TypeError):
                firmware_count = 0
            system_path = self.get_system_directory(retro_config)
            notes = core_config['notes'] or ''
            checksums = {}
            if notes.startswith('Suggested md5sums:'):
                parts = notes.split('|')
                for part in parts[1:]:
                    checksum, filename = part.split(' = ')
                    checksums[filename] = checksum
            for index in range(firmware_count):
                firmware_filename = core_config['firmware%d_path' % index]
                firmware_path = os.path.join(system_path, firmware_filename)
                if os.path.exists(firmware_path):
                    if firmware_filename in checksums:
                        checksum = system.get_md5_hash(firmware_path)
                        if checksum == checksums[firmware_filename]:
                            checksum_status = 'Checksum good'
                        else:
                            checksum_status = 'Checksum failed'
                    else:
                        checksum_status = 'No checksum info'
                    logger.info("Firmware '{}' found ({})".format(
                        firmware_filename, checksum_status))
                else:
                    logger.warning(
                        "Firmware '{}' not found!".format(firmware_filename))

                # Before closing issue #431
                # TODO check for firmware*_opt and display an error message if
                # firmware is missing
                # TODO Add dialog for copying the firmware in the correct
                # location

        return True
Exemplo n.º 9
0
    def prelaunch(self):
        config_file = self.get_config_file()

        # Create retroarch.cfg if it doesn't exist.
        if not system.path_exists(config_file):
            f = open(config_file, "w")
            f.write("# Lutris RetroArch Configuration")
            f.close()

            # Build the default config settings.
            retro_config = RetroConfig(config_file)
            retro_config["libretro_directory"] = get_default_config_path("cores")
            retro_config["libretro_info_path"] = get_default_config_path("info")
            retro_config["content_database_path"] = get_default_config_path("database/rdb")
            retro_config["cheat_database_path"] = get_default_config_path("database/cht")
            retro_config["cursor_directory"] = get_default_config_path("database/cursors")
            retro_config["screenshot_directory"] = get_default_config_path("screenshots")
            retro_config["input_remapping_directory"] = get_default_config_path("remaps")
            retro_config["video_shader_dir"] = get_default_config_path("shaders")
            retro_config["core_assets_directory"] = get_default_config_path("downloads")
            retro_config["thumbnails_directory"] = get_default_config_path("thumbnails")
            retro_config["playlist_directory"] = get_default_config_path("playlists")
            retro_config["joypad_autoconfig_dir"] = get_default_config_path("autoconfig")
            retro_config["rgui_config_directory"] = get_default_config_path("config")
            retro_config["overlay_directory"] = get_default_config_path("overlay")
            retro_config["assets_directory"] = get_default_config_path("assets")
            retro_config.save()
        else:
            retro_config = RetroConfig(config_file)

        core = self.game_config.get("core")
        info_file = os.path.join(
            get_default_config_path("info"), "{}_libretro.info".format(core)
        )
        if system.path_exists(info_file):
            core_config = RetroConfig(info_file)
            try:
                firmware_count = int(core_config["firmware_count"])
            except (ValueError, TypeError):
                firmware_count = 0
            system_path = self.get_system_directory(retro_config)
            notes = core_config["notes"] or ""
            checksums = {}
            if notes.startswith("Suggested md5sums:"):
                parts = notes.split("|")
                for part in parts[1:]:
                    checksum, filename = part.split(" = ")
                    checksums[filename] = checksum
            for index in range(firmware_count):
                firmware_filename = core_config["firmware%d_path" % index]
                firmware_path = os.path.join(system_path, firmware_filename)
                if system.path_exists(firmware_path):
                    if firmware_filename in checksums:
                        checksum = system.get_md5_hash(firmware_path)
                        if checksum == checksums[firmware_filename]:
                            checksum_status = "Checksum good"
                        else:
                            checksum_status = "Checksum failed"
                    else:
                        checksum_status = "No checksum info"
                    logger.info(
                        "Firmware '%s' found (%s)", firmware_filename, checksum_status
                    )
                else:
                    logger.warning("Firmware '%s' not found!", firmware_filename)

                # Before closing issue #431
                # TODO check for firmware*_opt and display an error message if
                # firmware is missing
                # TODO Add dialog for copying the firmware in the correct
                # location

        return True