Пример #1
0
 def test_can_filter_by_installed_games(self):
     pga.add_game(name="installed_game", runner="Linux", installed=1)
     pga.add_game(name="bang", runner="Linux", installed=0)
     game_list = pga.get_games(filter_installed=True)
     print game_list
     self.assertEqual(len(game_list), 1)
     self.assertEqual(game_list[0]['name'], 'installed_game')
Пример #2
0
 def test_can_filter_by_installed_games(self):
     pga.add_game(name="installed_game", runner="Linux", installed=1)
     pga.add_game(name="bang", runner="Linux", installed=0)
     game_list = pga.get_games(filter_installed=True)
     print game_list
     self.assertEqual(len(game_list), 1)
     self.assertEqual(game_list[0]['name'], 'installed_game')
Пример #3
0
    def sync_missing_games(not_in_local, remote_library, caller=None):
        """Get missing games in local library from remote library.

        :param caller: The LutrisWindow object
        :return: The slugs of the added games
        :rtype: set
        """
        if not not_in_local:
            return set()

        for game in remote_library:
            slug = game['slug']
            # Sync
            if slug in not_in_local:
                logger.debug("Adding to local library: %s", slug)
                pga.add_game(
                    game['name'], slug=slug, year=game['year'],
                    updated=game['updated'], steamid=game['steamid']
                )
                if caller:
                    caller.add_game_to_view(slug)
            else:
                not_in_local.discard(slug)
        logger.debug("%d games added", len(not_in_local))
        return not_in_local
Пример #4
0
 def test_game_with_same_slug_is_updated(self):
     pga.add_game(name="some game", runner="linux")
     game = pga.get_game_by_field("some-game", "slug")
     self.assertFalse(game['directory'])
     pga.add_or_update(name="some game", runner='linux', directory="/foo")
     game = pga.get_game_by_field("some-game", "slug")
     self.assertEqual(game['directory'], '/foo')
Пример #5
0
def sync():
    remote_library = get_library()['games']
    remote_slugs = set([game['slug'] for game in remote_library])
    local_libray = pga.get_games()
    local_slugs = set([game['slug'] for game in local_libray])
    not_in_local = remote_slugs.difference(local_slugs)
    for game in remote_library:
        if game['slug'] in not_in_local:
            pga.add_game(game['name'], slug=game['slug'])
    return not_in_local
Пример #6
0
    def run_no_installer_dialog(self):
        """Open dialog for 'no script available' situation."""
        dlg = NoInstallerDialog(self)
        if dlg.result == dlg.MANUAL_CONF:
            game_data = pga.get_game_by_field(self.game_slug, "slug")

            if game_data and "slug" in game_data:
                # Game data already exist locally.
                game = Game(game_data["id"])
            else:
                # Try to load game data from remote.
                games = api.get_api_games([self.game_slug])

                if games and len(games) >= 1:
                    remote_game = games[0]
                    game_data = {
                        "name": remote_game["name"],
                        "slug": remote_game["slug"],
                        "year": remote_game["year"],
                        "updated": remote_game["updated"],
                        "steamid": remote_game["steamid"],
                    }
                    game = Game(pga.add_game(**game_data))
                else:
                    game = None
            AddGameDialog(self.parent, game=game)
        elif dlg.result == dlg.NEW_INSTALLER:
            webbrowser.open(settings.GAME_URL % self.game_slug)
Пример #7
0
    def run_no_installer_dialog(self):
        """Open dialog for 'no script available' situation."""
        dlg = NoInstallerDialog(self)
        if dlg.result == dlg.MANUAL_CONF:
            game_data = pga.get_game_by_field(self.game_slug, 'slug')

            if game_data and 'slug' in game_data:
                # Game data already exist locally.
                game = Game(game_data['id'])
            else:
                # Try to load game data from remote.
                games = api.get_games([self.game_slug])

                if games and len(games) >= 1:
                    remote_game = games[0]
                    game_data = {
                        'name': remote_game['name'],
                        'slug': remote_game['slug'],
                        'year': remote_game['year'],
                        'updated': remote_game['updated'],
                        'steamid': remote_game['steamid']
                    }
                    game = Game(pga.add_game(**game_data))
                else:
                    game = None

            AddGameDialog(
                self.parent,
                game=game,
                callback=lambda: self.notify_install_success(game_data['id'])
            )
        elif dlg.result == dlg.NEW_INSTALLER:
            webbrowser.open(settings.GAME_URL % self.game_slug)
Пример #8
0
    def run_no_installer_dialog(self):
        """Open dialog for 'no script available' situation."""
        dlg = NoInstallerDialog(self)
        if dlg.result == dlg.MANUAL_CONF:
            game_data = pga.get_game_by_field(self.game_slug, 'slug')

            if game_data and 'slug' in game_data:
                # Game data already exist locally.
                game = Game(game_data['id'])
            else:
                # Try to load game data from remote.
                games = api.get_games([self.game_slug])

                if games and len(games) >= 1:
                    remote_game = games[0]
                    game_data = {
                        'name': remote_game['name'],
                        'slug': remote_game['slug'],
                        'year': remote_game['year'],
                        'updated': remote_game['updated'],
                        'steamid': remote_game['steamid']
                    }
                    game = Game(pga.add_game(**game_data))
                else:
                    game = None

            AddGameDialog(
                self.parent,
                game=game,
                callback=lambda: self.notify_install_success(game_data['id']))
        elif dlg.result == dlg.NEW_INSTALLER:
            webbrowser.open(settings.GAME_URL % self.game_slug)
Пример #9
0
    def run_no_installer_dialog(self):
        """Open dialog for 'no script available' situation."""
        dlg = NoInstallerDialog(self)
        if dlg.result == dlg.MANUAL_CONF:
            game_data = pga.get_game_by_field(self.game_slug, "slug")

            if game_data and "slug" in game_data:
                # Game data already exist locally.
                game = Game(game_data["id"])
            else:
                # Try to load game data from remote.
                games = api.get_api_games([self.game_slug])

                if games and len(games) >= 1:
                    remote_game = games[0]
                    game_data = {
                        "name": remote_game["name"],
                        "slug": remote_game["slug"],
                        "year": remote_game["year"],
                        "updated": remote_game["updated"],
                        "steamid": remote_game["steamid"],
                    }
                    game = Game(pga.add_game(**game_data))
                else:
                    game = None
            AddGameDialog(self.parent, game=game)
        elif dlg.result == dlg.NEW_INSTALLER:
            webbrowser.open(settings.GAME_URL % self.game_slug)
Пример #10
0
    def add_game(self, _button):
        """OK button pressed in the Add Game Dialog"""
        name = self.realname_entry.get_text()
        self.lutris_config.config["realname"] = name
        self.lutris_config.config["runner"] = self.runner_class

        if self.runner_class and name:

            game_identifier = self.lutris_config.save(config_type="game")
            self.game_info = {"name": name,
                              "runner": self.runner_class,
                              "slug": game_identifier}

            runner = import_runner(self.runner_class)(self.lutris_config)
            self.game_info['directory'] = runner.get_game_path()
            pga.add_game(**self.game_info)
            self.destroy()
Пример #11
0
def sync(caller=None):
    logger.debug("Syncing game library")
    remote_library = get_library()['games']
    remote_slugs = set([game['slug'] for game in remote_library])
    logger.debug("%d games in remote library", len(remote_slugs))
    local_libray = pga.get_games()
    local_slugs = set([game['slug'] for game in local_libray])
    logger.debug("%d games in local library", len(local_slugs))
    not_in_local = remote_slugs.difference(local_slugs)
    for game in remote_library:
        if game['slug'] in not_in_local:
            logger.debug("Adding %s to local library", game['slug'])
            pga.add_game(game['name'], slug=game['slug'], year=game['year'])
            if caller:
                caller.add_game_to_view(game['slug'])
    logger.debug("%d games added", len(not_in_local))
    return not_in_local
Пример #12
0
def sync(caller=None):
    logger.debug("Syncing game library")
    remote_library = get_library()['games']
    remote_slugs = set([game['slug'] for game in remote_library])
    logger.debug("%d games in remote library", len(remote_slugs))
    local_libray = pga.get_games()
    local_slugs = set([game['slug'] for game in local_libray])
    logger.debug("%d games in local library", len(local_slugs))
    not_in_local = remote_slugs.difference(local_slugs)
    for game in remote_library:
        if game['slug'] in not_in_local:
            logger.debug("Adding %s to local library", game['slug'])
            pga.add_game(game['name'], slug=game['slug'], year=game['year'])
            if caller:
                caller.add_game_to_view(game['slug'])
    logger.debug("%d games added", len(not_in_local))
    return not_in_local
Пример #13
0
    def manually_configure_game(self):
        game_data = pga.get_game_by_field(self.game_slug, "slug")

        if game_data and "slug" in game_data:
            # Game data already exist locally.
            game = Game(game_data["id"])
        else:
            # Try to load game data from remote.
            games = api.get_api_games([self.game_slug])

            if games and len(games) >= 1:
                remote_game = games[0]
                game_data = {
                    "name": remote_game["name"],
                    "slug": remote_game["slug"],
                    "year": remote_game["year"],
                    "updated": remote_game["updated"],
                    "steamid": remote_game["steamid"],
                }
                game = Game(pga.add_game(**game_data))
            else:
                game = None
        AddGameDialog(self.parent, game=game)
Пример #14
0
 def test_does_set_installed_games(self):
     pga.add_game(name="some game", runner='linux', directory="/home")
     pga.set_installed_games()
     test_game = pga.get_games()[0]
     self.assertEqual(test_game['installed'], 1)
Пример #15
0
 def test_does_set_installed_games(self):
     pga.add_game(name="some game", runner='linux', directory="/home")
     pga.set_installed_games()
     test_game = pga.get_games()[0]
     self.assertEqual(test_game['installed'], 1)
Пример #16
0
 def test_filter(self):
     pga.add_game(name="foobar", runner="Linux")
     pga.add_game(name="bang", runner="Linux")
     game_list = pga.get_games(name_filter='bang')
     self.assertEqual(len(game_list), 1)
     self.assertEqual(game_list[0]['name'], 'bang')
Пример #17
0
 def test_delete_game(self):
     pga.delete_game(self.game_id)
     game_list = pga.get_games()
     self.assertEqual(len(game_list), 0)
     self.game_id = pga.add_game(name="LutrisTest", runner="Linux")
Пример #18
0
 def setUp(self):
     super(TestPersonnalGameArchive, self).setUp()
     self.game_id = pga.add_game(name="LutrisTest", runner="Linux")
Пример #19
0
 def test_game_slugs_must_be_unique(self):
     pga.add_game(name="unique game", runner="Linux")
     with self.assertRaises(IntegrityError):
         pga.add_game(name="unique game", runner="Linux")
Пример #20
0
 def setUp(self):
     pga.PGA_DB = TEST_PGA_PATH
     if os.path.exists(TEST_PGA_PATH):
         os.remove(TEST_PGA_PATH)
     pga.create()
     pga.add_game(name="LutrisTest", runner="Linux")