def _download_steam_data(self, file_uri, file_id): try: parts = file_uri.split(":", 2) steam_rel_path = parts[2].strip() except IndexError: raise ScriptingError("Malformed steam path: %s" % file_uri) if steam_rel_path == "/": steam_rel_path = "." self.steam_data = {"appid": parts[1], "steam_rel_path": steam_rel_path, "file_id": file_id} if parts[0] == "$WINESTEAM": appid = self.steam_data["appid"] logger.debug("Getting Wine Steam data for appid %s" % appid) self.parent.set_status("Getting Wine Steam game data") self.steam_data["platform"] = "windows" # Check that wine is installed wine_runner = wine.wine() if not wine_runner.is_installed(): wine_runner.install() # Getting data from Wine Steam steam_runner = winesteam.winesteam() if not steam_runner.is_installed(): winesteam.download_steam( downloader=self.parent.start_download, callback=self.parent.on_steam_downloaded ) else: self.install_steam_game(winesteam.winesteam) else: # Getting data from Linux Steam self.parent.set_status("Getting Steam game data") self.steam_data["platform"] = "linux" self.install_steam_game(steam.steam)
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 _download_steam_data(self, file_uri, file_id): try: parts = file_uri.split(":", 2) steam_rel_path = parts[2].strip() except IndexError: raise ScriptingError("Malformed steam path: %s" % file_uri) if steam_rel_path == "/": steam_rel_path = "." self.steam_data = { 'appid': parts[1], 'steam_rel_path': steam_rel_path, 'file_id': file_id } if parts[0] == '$WINESTEAM': appid = self.steam_data['appid'] logger.debug("Getting Wine Steam data for appid %s" % appid) self.parent.set_status('Getting Wine Steam game data') self.steam_data['platform'] = "windows" # Check that wine is installed wine_runner = wine.wine() if not wine_runner.is_installed(): wine_runner.install() # Getting data from Wine Steam steam_runner = winesteam.winesteam() if not steam_runner.is_installed(): winesteam.download_steam( downloader=self.parent.start_download, callback=self.parent.on_steam_downloaded ) else: self.install_steam_game(winesteam.winesteam) else: # Getting data from Linux Steam self.parent.set_status('Getting Steam game data') self.steam_data['platform'] = "linux" self.install_steam_game(steam.steam) self.iter_game_files() return True
def _download_file(self, game_file): """Download a file referenced in the installer script Game files can be either a string, containing the location of the file to fetch or a dict with the following keys: - url : location of file, if not present, filename will be used this should be the case for local files - filename : force destination filename when url is present or path of local file """ # Setup file_id, file_uri and local filename file_id = game_file.keys()[0] if isinstance(game_file[file_id], dict): filename = game_file[file_id]['filename'] file_uri = game_file[file_id]['url'] else: file_uri = game_file[file_id] filename = os.path.basename(file_uri) if file_uri.startswith("/"): file_uri = "file://" + file_uri elif file_uri.startswith(("$WINESTEAM", "$STEAM")): # Download Steam data try: parts = file_uri.split(":", 2) steam_rel_path = parts[2].strip() except IndexError: raise ScriptingError("Malformed steam path: %s" % file_uri) if steam_rel_path == "/": steam_rel_path = "." self.steam_data = { 'appid': parts[1], 'steam_rel_path': steam_rel_path, 'file_id': file_id } if parts[0] == '$WINESTEAM': appid = self.steam_data['appid'] logger.debug("Getting Wine Steam data for appid %s" % appid) self.parent.set_status('Getting Wine Steam game data') self.steam_data['platform'] = "windows" # Check that wine is installed wine_runner = wine.wine() if not wine_runner.is_installed(): wine_runner.install() # Getting data from Wine Steam steam_runner = winesteam.winesteam() if not steam_runner.is_installed(): winesteam.download_steam( downloader=self.parent.start_download, callback=self.parent.on_steam_downloaded ) else: self.install_steam_game(winesteam.winesteam) return else: # Getting data from Linux Steam self.parent.set_status('Getting Steam game data') self.steam_data['platform'] = "linux" self.install_steam_game(steam.steam) return logger.debug("Fetching [%s]: %s" % (file_id, file_uri)) # Check for file availability in PGA pga_uri = pga.check_for_file(self.game_slug, file_id) if pga_uri: file_uri = pga_uri # Setup destination path dest_file = os.path.join(self.download_cache_path, filename) if file_uri.startswith("N/A"): # Ask the user where is the file located parts = file_uri.split(":", 1) if len(parts) == 2: message = parts[1] else: message = "Please select file '%s'" % file_id self.current_file_id = file_id self.parent.ask_user_for_file(message) return if os.path.exists(dest_file): logger.debug("Destination file exists") if settings.KEEP_CACHED_ASSETS: self.game_files[file_id] = dest_file self.iter_game_files() return else: os.remove(dest_file) # Change parent's status self.parent.set_status('Fetching %s' % file_uri) self.game_files[file_id] = dest_file self.parent.start_download(file_uri, dest_file)