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
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" description = "Multi system emulator" runnable_alone = True