def test_game_with_same_slug_is_updated(self): pga.add_game(name="some game", runner="linux") game = pga.get_game_by_slug("some-game") self.assertFalse(game['directory']) pga.add_or_update(name="some game", runner='linux', directory="/foo") game = pga.get_game_by_slug("some-game") self.assertEqual(game['directory'], '/foo')
def initialize(self, game=None, callback=None): self.game_slug = game game_info = pga.get_game_by_slug(game) self.callback = callback game_name = game_info['name'] self.substitute_label(self.builder.get_object('description_label'), 'game', game_name) self.substitute_label( self.builder.get_object('remove_from_library_button'), 'game', game_name ) game_directory = game_info['directory'] remove_contents_button = self.builder.get_object( 'remove_contents_button' ) if not game_directory: remove_contents_button.set_sensitive(False) game_directory = "disk" self.substitute_label(remove_contents_button, 'path', game_directory) cancel_button = self.builder.get_object('cancel_button') cancel_button.connect('clicked', self.on_close) apply_button = self.builder.get_object('apply_button') apply_button.connect('clicked', self.on_apply_button_clicked)
def _check_dependecy(self): game = pga.get_game_by_slug(self.requires) if not game or not game['directory']: raise ScriptingError( "You need to install {} before".format(self.requires) ) self.target_path = game['directory']
def _check_dependecy(self): # XXX Maybe handle this with Game instead of hitting directly the PGA? game = pga.get_game_by_slug(self.requires) if not game or not game['directory']: raise ScriptingError("You need to install {} before".format( self.requires)) self.target_path = game['directory']
def _check_dependency(self): # XXX Maybe handle this with Game instead of hitting directly the PGA? game = pga.get_game_by_slug(self.requires, field='installer_slug') if not game or not game['directory']: raise ScriptingError( "You need to install {} before".format(self.requires) ) self.target_path = game['directory']
def __init__(self, config=None): """Initialize runner.""" self.depends = None self.arch = get_arch() self.logger = logger self.config = config self.game_data = {} if config: self.game_data = pga.get_game_by_slug(self.config.game_slug)
def sync_game_details(remote_library, caller): """Update local game details, :param caller: The LutrisWindow object :return: The slugs of the updated games. :rtype: set """ if not remote_library: return set() updated = set() # Get remote games (TODO: use this when switched API to DRF) # remote_games = get_games(sorted(local_slugs)) # if not remote_games: # return set() for game in remote_library: slug = game['slug'] sync = False sync_icons = True local_game = pga.get_game_by_slug(slug) if not local_game: continue # Sync updated if game['updated'] > local_game['updated']: sync = True # Sync new DB fields else: for key, value in local_game.iteritems(): if value or key not in game: continue if game[key]: sync = True sync_icons = False if not sync: continue logger.debug("Syncing details for %s" % slug) pga.add_or_update( local_game['name'], local_game['runner'], slug, year=game['year'], updated=game['updated'], steamid=game['steamid'] ) caller.view.update_row(game) # Sync icons (TODO: Only update if icon actually updated) if sync_icons: resources.download_icon(slug, 'banner', overwrite=True, callback=caller.on_image_downloaded) resources.download_icon(slug, 'icon', overwrite=True, callback=caller.on_image_downloaded) updated.add(slug) logger.debug("%d games updated", len(updated)) return updated
def __init__(self, config=None): """Initialize runner.""" self.depends = None self.arch = get_arch() self.logger = logger self.config = config or {} self.settings = self.config self.game_data = None if config: self.game_data = pga.get_game_by_slug(self.config.game)
def sync_game_details(remote_library): """Update local game details, :return: The slugs of the updated games. :rtype: set """ if not remote_library: return set() updated = set() # Get remote games (TODO: use this when switched API to DRF) # remote_games = get_games(sorted(local_slugs)) # if not remote_games: # return set() for game in remote_library: slug = game["slug"] sync = False sync_icons = True local_game = pga.get_game_by_slug(slug) if not local_game: continue # Sync updated if game["updated"] > local_game["updated"]: sync = True # Sync new DB fields else: for key, value in local_game.iteritems(): if value or key not in game: continue if game[key]: sync = True sync_icons = False if not sync: continue logger.debug("Syncing details for %s" % slug) pga.add_or_update( local_game["name"], local_game["runner"], slug, year=game["year"], updated=game["updated"], steamid=game["steamid"], ) # Sync icons (TODO: Only update if icon actually updated) if sync_icons: resources.download_icon(slug, "banner", overwrite=True) resources.download_icon(slug, "icon", overwrite=True) updated.add(slug) logger.debug("%d games updated", len(updated)) return updated
def __init__(self, slug): self.slug = slug self.game_thread = None self.heartbeat = None self.game_config = None game_data = pga.get_game_by_slug(slug) self.runner_name = game_data['runner'] self.directory = game_data['directory'] self.name = game_data['name'] self.load_config()
def add_game(self, game_slug): """Add a game into the store.""" if not game_slug: return game_data = pga.get_game_by_slug(game_slug) pixbuf = get_pixbuf_for_game(game_data['slug'], self.icon_type, is_installed=game_data['installed']) name = game_data['name'].replace('&', "&") self.store.append( (game_data['slug'], name, pixbuf, str(game_data['year']), game_data['runner'], game_data['installed']) )
def __init__(self, slug): self.slug = slug self.runner = None self.game_thread = None self.heartbeat = None self.game_config = None game_data = pga.get_game_by_slug(slug) self.runner_name = game_data.get('runner') self.directory = game_data.get('directory') self.name = game_data.get('name') self.is_installed = bool(game_data.get('installed')) self.load_config() self.resolution_changed = False self.original_outputs = display.get_outputs()
def __init__(self, slug): self.slug = slug self.runner = None self.game_thread = None self.heartbeat = None self.config = None game_data = pga.get_game_by_slug(slug) self.runner_name = game_data.get('runner') or '' self.directory = game_data.get('directory') or '' self.name = game_data.get('name') or '' self.is_installed = bool(game_data.get('installed')) or False self.year = game_data.get('year') or '' self.load_config() self.resolution_changed = False self.original_outputs = None
def update_existing_games(): for game in updated.difference(added): self.view.update_row(pga.get_game_by_slug(game)) for game in installed.difference(added): if not self.view.get_row_by_slug(game): self.view.add_game(game) self.view.set_installed(Game(game)) for game in uninstalled.difference(added): self.view.set_uninstalled(game) self.sidebar_treeview.update() self.set_status("Library synced") icons_sync = AsyncCall(self.sync_icons, None, stoppable=True) self.threads_stop_requests.append(icons_sync.stop_request)
def __init__(self, slug): self.slug = slug self.runner = None self.game_thread = None self.heartbeat = None self.config = None self.killswitch = None self.state = self.STATE_IDLE self.game_log = '' game_data = pga.get_game_by_slug(slug) self.runner_name = game_data.get('runner') or '' self.directory = game_data.get('directory') or '' self.name = game_data.get('name') or '' self.is_installed = bool(game_data.get('installed')) or False self.year = game_data.get('year') or '' self.load_config() self.resolution_changed = False self.original_outputs = None
def __init__(self, runner_slug=None, game_slug=None, level=None): self.game_slug = game_slug self.runner_slug = runner_slug if game_slug and not runner_slug: self.runner_slug = pga.get_game_by_slug(game_slug).get('runner') # Cascaded config sections (for reading) self.game_config = {} self.runner_config = {} self.system_config = {} # Raw (non-cascaded) sections (for writing) self.raw_game_config = {} self.raw_runner_config = {} self.raw_system_config = {} self.raw_config = {} # Set config level self.level = level if not level: if game_slug: self.level = 'game' elif runner_slug: self.level = 'runner' else: self.level = 'system' # Init and load config files self.game_level = {'system': {}, self.runner_slug: {}, 'game': {}} self.runner_level = {'system': {}, self.runner_slug: {}} self.system_level = {'system': {}} self.game_level.update(read_yaml_from_file(self.game_config_path)) self.runner_level.update(read_yaml_from_file(self.runner_config_path)) self.system_level.update(read_yaml_from_file(self.system_config_path)) self.update_cascaded_config() self.update_raw_config()