Coverage for lutris.runners.snes9x : 50%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding:Utf-8 -*-
"""Runs Super Nintendo games with Snes9x"""
{ "option": "main_file", "type": "file", "default_path": "game_path", "label": "ROM" } ]
{ "option": "fullscreen", "type": "bool", "label": "Fullscreen", "default": "1" }, { "option": "maintain_aspect_ratio", "type": "bool", "label": "Maintain aspect ratio", "default": "1" }, { "option": "sound_driver", "type": "one_choice", "label": "Sound driver", "choices": (("OSS", "0"), ("SDL", "1"), ("ALSA", "2")), "default": "1" } ]
else:
".snes9x/snes9x.xml") logger.debug("Creating new config file") subprocess.Popen(" ".join(self.get_executable()) + " -help", shell=True) value = "1" if value else "0"
""" Install snes9x from lutris.net """ logger.debug("Installing snes9x") tarball_url = SNES9X_64 if self.arch == 'x64' else SNES9X_32 tarball_file = os.path.basename(tarball_url) dest = os.path.join(settings.TMP_PATH, tarball_file) logger.debug("Downloading %s" % tarball_url) urllib.urlretrieve(tarball_url, dest)
logger.debug("Extracting %s" % dest) extract_archive(dest, SNES9X_RUNNER_DIR)
lib_dir = os.path.join(SNES9X_RUNNER_DIR, "lib") os.mkdir(lib_dir)
libpng_url = LIBPNG_64 if self.arch == 'x64' else LIBPNG_32 libpng_file = os.path.basename(libpng_url) lib_abspath = os.path.join(lib_dir, libpng_file) logger.debug("Downloading %s" % libpng_url) urllib.urlretrieve(libpng_url, lib_abspath) logger.debug("Extracting %s" % lib_abspath) decompress_gz(lib_abspath) logger.debug("Creating lib symlinks") os.link(lib_abspath[:-3], lib_abspath[:-5]) os.link(lib_abspath[:-3], lib_abspath[:-8])
""" Return the `runner_options` class attribute as a dictionnary with option name as key. """ option_dict = {} for option in self.runner_options: option_dict[option['option']] = option return option_dict
""" Run Super Nintendo game """ options = self.options_as_dict() runner_options = self.settings.get('snes9x') for option_name in options: if runner_options: self.set_option( option_name, runner_options.get( option_name, options[option_name].get('default') ) )
rom = self.settings["game"].get("main_file") if not os.path.exists(rom): return {'error': 'FILE_NOT_FOUND', 'file': rom}
launch_info = {'command': [self.get_executable(), "\"%s\"" % rom]}
lib_path = os.path.join(SNES9X_RUNNER_DIR, "lib") if os.path.exists(lib_path): launch_info['ld_library_path'] = lib_path
return launch_info |