def _iter_proton_locations(): """Iterate through all existing Proton locations""" for path in [os.path.join(p, "common") for p in steam().get_steamapps_dirs()]: if os.path.isdir(path): yield path for path in [os.path.join(p, "") for p in steam().get_steamapps_dirs()]: if os.path.isdir(path): yield path
def _substitute(self, template_string): """Replace path aliases with real paths.""" if template_string is None: logger.warning("No template string given") return "" replacements = { "GAMEDIR": self.target_path, "CACHE": self.cache_path, "HOME": os.path.expanduser("~"), "STEAM_DATA_DIR": steam.steam().steam_data_dir, "DISC": self.game_disc, "USER": os.getenv("USER"), "INPUT": self._get_last_user_input(), "VERSION": self.installer.version, "RESOLUTION": "x".join(self.current_resolution), "RESOLUTION_WIDTH": self.current_resolution[0], "RESOLUTION_HEIGHT": self.current_resolution[1], "WINEBIN": self.get_wine_path(), } replacements.update(self.installer.variables) # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data["alias"] if alias: replacements[alias] = input_data["value"] replacements.update(self.game_files) if str(template_string).replace("-", "_") in self.game_files: template_string = template_string.replace("-", "_") return system.substitute(template_string, replacements)
def __init__(self, steam_uri, file_id): """ Params: steam_uri: Colon separated game info containing: - $STEAM - The Steam appid - The relative path of files to retrieve file_id: The lutris installer internal id for the game files """ super().__init__() self.steam_poll = None self.prev_states = [] # Previous states for the Steam installer self.state = "" self.install_start_time = None self.steam_uri = steam_uri self.stop_func = None self.cancelled = False self._runner = None self.file_id = file_id try: _steam, appid, path = self.steam_uri.split(":", 2) except ValueError: raise ScriptingError("Malformed steam path: %s" % self.steam_uri) self.appid = appid self.path = path self.platform = "linux" self.runner = steam.steam()
def _substitute(self, template_string): """Replace path aliases with real paths.""" if str(template_string).lower() == 'true': return True if str(template_string).lower() == 'false': return False replacements = { "GAMEDIR": self.target_path, "CACHE": self.cache_path, "HOME": os.path.expanduser("~"), "STEAM_DATA_DIR": steam.steam().steam_data_dir, "DISC": self.game_disc, "USER": os.getenv('USER'), "INPUT": self._get_last_user_input(), "VERSION": self.version, } # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data['alias'] if alias: replacements[alias] = input_data['value'] replacements.update(self.game_files) return system.substitute(template_string, replacements)
def _get_string_replacements(self): """Return a mapping of variables to their actual value""" replacements = { "GAMEDIR": self.target_path, "CACHE": self.cache_path, "HOME": os.path.expanduser("~"), "STEAM_DATA_DIR": steam.steam().steam_data_dir, "DISC": self.game_disc, "USER": os.getenv("USER"), "INPUT": self.user_inputs[-1]["value"] if self.user_inputs else "", "VERSION": self.installer.version, "RESOLUTION": "x".join(self.current_resolution), "RESOLUTION_WIDTH": self.current_resolution[0], "RESOLUTION_HEIGHT": self.current_resolution[1], "RESOLUTION_WIDTH_HEX": hex(int(self.current_resolution[0])), "RESOLUTION_HEIGHT_HEX": hex(int(self.current_resolution[1])), "WINEBIN": self.get_wine_path(), } replacements.update(self.installer.variables) # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data["alias"] if alias: replacements[alias] = input_data["value"] replacements.update(self.game_files) return replacements
def runner(self): """Return the runner instance used by this install""" if not self._runner: if self.platform == "windows": self._runner = winesteam.winesteam() self._runner = steam.steam() return self._runner
def check_steam_install(self): """Checks that the required version of Steam is installed. Return a boolean indicating whether is it or not. """ if self.steam_data['platform'] == 'windows': # Check that wine is installed wine_runner = wine.wine() if not wine_runner.is_installed(): logger.debug('Wine is not installed') wine_runner.install( downloader=self.parent.start_download, callback=self.check_steam_install ) return False # Getting data from Wine Steam steam_runner = winesteam.winesteam() if not steam_runner.is_installed(): logger.debug('Winesteam not installed') winesteam.download_steam( downloader=self.parent.start_download, callback=self.on_steam_downloaded ) return False return True else: steam_runner = steam.steam() if not steam_runner.is_installed(): raise ScriptingError( "Install Steam for Linux and start installer again" ) return True
def sync_steam_local(self): """Sync Steam games in library with Steam and Wine Steam""" steamrunner = steam() winesteamrunner = winesteam() installed = set() uninstalled = set() # Get installed steamapps installed_steamapps = self.get_installed_steamapps(steamrunner) installed_winesteamapps = self.get_installed_steamapps(winesteamrunner) for game_info in self.library: slug = game_info['slug'] runner = game_info['runner'] steamid = game_info['steamid'] installed_in_steam = steamid in installed_steamapps installed_in_winesteam = steamid in installed_winesteamapps # Set installed if not game_info['installed']: if not installed_in_steam: # (Linux Steam only) continue logger.debug("Setting %s as installed" % game_info['name']) config_id = (game_info['configpath'] or config.make_game_config_id(slug)) game_id = pga.add_or_update( name=game_info['name'], runner='steam', slug=slug, installed=1, configpath=config_id, ) game_config = config.LutrisConfig( runner_slug='steam', game_config_id=config_id, ) game_config.raw_game_config.update({'appid': str(steamid)}) game_config.save() installed.add(game_id) # Set uninstalled elif not (installed_in_steam or installed_in_winesteam): if runner not in ['steam', 'winesteam']: continue if runner == 'steam' and not steamrunner.is_installed(): continue if runner == 'winesteam' and not winesteamrunner.is_installed(): continue logger.debug("Setting %(name)s (%(steamid)s) as uninstalled", game_info) game_id = pga.add_or_update( name=game_info['name'], runner='', slug=game_info['slug'], installed=0 ) uninstalled.add(game_id) return (installed, uninstalled)
def get_proton(): """Get the Folder that contains all the Proton versions. Can probably be improved""" for path in [os.path.join(p, "common") for p in steam().get_steamapps_dirs()]: if os.path.isdir(path): proton_versions = [p for p in os.listdir(path) if "Proton" in p] for version in proton_versions: if system.path_exists(os.path.join(path, version, "dist/bin/wine")): return path return None
def sync_steam_local(self, caller): """Sync Steam games in library with Steam and Wine Steam""" logger.debug("Syncing local steam games") steamrunner = steam() winesteamrunner = winesteam() # Get installed steamapps installed_steamapps = self._get_installed_steamapps(steamrunner) installed_winesteamapps = self._get_installed_steamapps(winesteamrunner) for game_info in self.library: runner = game_info['runner'] game = Game(game_info['slug']) steamid = game_info['steamid'] installed_in_steam = steamid in installed_steamapps installed_in_winesteam = steamid in installed_winesteamapps # Set installed if not game_info['installed']: if not installed_in_steam: # (Linux Steam only) continue logger.debug("Setting %s as installed" % game_info['name']) pga.add_or_update(game_info['name'], 'steam', game_info['slug'], installed=1) game.config.game_config.update({'game': {'appid': str(steamid)}}) game.config.save() caller.view.set_installed(Game(game_info['slug'])) # Set uninstalled elif not (installed_in_steam or installed_in_winesteam): if runner not in ['steam', 'winesteam']: continue if runner == 'steam' and not steamrunner.is_installed(): continue if runner == 'winesteam' and not winesteamrunner.is_installed(): continue logger.debug("Setting %s as uninstalled" % game_info['name']) pga.add_or_update(game_info['name'], '', game_info['slug'], installed=0) caller.view.set_uninstalled(game_info['slug'])
def get_steamapps_paths(flat=False): from lutris.runners import winesteam, steam if flat: steamapps_paths = [] else: steamapps_paths = {'linux': [], 'windows': []} winesteam_runner = winesteam.winesteam() steam_runner = steam.steam() for folder in steam_runner.get_steamapps_dirs(): if flat: steamapps_paths.append(folder) else: steamapps_paths['linux'].append(folder) for folder in winesteam_runner.get_steamapps_dirs(): if flat: steamapps_paths.append(folder) else: steamapps_paths['windows'].append(folder) return steamapps_paths
def sync_steam_local(self): """Sync Steam games in library with Steam and Wine Steam""" logger.debug("Syncing local steam games") steamrunner = steam() winesteamrunner = winesteam() installed = set() uninstalled = set() # Get installed steamapps installed_steamapps = self._get_installed_steamapps(steamrunner) installed_winesteamapps = self._get_installed_steamapps(winesteamrunner) for game_info in self.library: slug = game_info["slug"] runner = game_info["runner"] steamid = game_info["steamid"] installed_in_steam = steamid in installed_steamapps installed_in_winesteam = steamid in installed_winesteamapps # Set installed if not game_info["installed"]: if not installed_in_steam: # (Linux Steam only) continue logger.debug("Setting %s as installed" % game_info["name"]) pga.add_or_update(game_info["name"], "steam", slug, installed=1) game_config = config.LutrisConfig(runner_slug="steam", game_slug=game_info["slug"]) game_config.raw_game_config.update({"appid": str(steamid)}) game_config.save() installed.add(slug) # Set uninstalled elif not (installed_in_steam or installed_in_winesteam): if runner not in ["steam", "winesteam"]: continue if runner == "steam" and not steamrunner.is_installed(): continue if runner == "winesteam" and not winesteamrunner.is_installed(): continue logger.debug("Setting %s as uninstalled" % game_info["name"]) pga.add_or_update(game_info["name"], "", game_info["slug"], installed=0) uninstalled.add(slug) return (installed, uninstalled)
def get_steamapps_paths(flat=False): from lutris.runners import winesteam, steam if flat: steamapps_paths = [] else: steamapps_paths = { 'linux': [], 'windows': [] } winesteam_runner = winesteam.winesteam() steam_runner = steam.steam() for folder in steam_runner.get_steamapps_dirs(): if flat: steamapps_paths.append(folder) else: steamapps_paths['linux'].append(folder) for folder in winesteam_runner.get_steamapps_dirs(): if flat: steamapps_paths.append(folder) else: steamapps_paths['windows'].append(folder) return steamapps_paths
def _substitute(self, template_string): """Replace path aliases with real paths.""" replacements = { "GAMEDIR": self.target_path, "CACHE": self.cache_path, "HOME": os.path.expanduser("~"), "STEAM_DATA_DIR": steam.steam().steam_data_dir, "DISC": self.game_disc, "USER": os.getenv("USER"), "INPUT": self._get_last_user_input(), "VERSION": self.version, "RESOLUTION": "x".join(self.current_resolution), "RESOLUTION_WIDTH": self.current_resolution[0], "RESOLUTION_HEIGHT": self.current_resolution[1], } # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data["alias"] if alias: replacements[alias] = input_data["value"] replacements.update(self.game_files) return system.substitute(template_string, replacements)
def get_steamapps_paths(): from lutris.runners import steam # pylint: disable=import-outside-toplevel return steam.steam().get_steamapps_dirs()