Beispiel #1
0
    def on_game_install(self, game):
        """Request installation of a game"""
        if game.service and game.service != "lutris":
            service = get_enabled_services()[game.service]()
            db_game = ServiceGameCollection.get_game(service.id, game.appid)

            try:
                game_id = service.install(db_game)
            except ValueError as e:
                logger.debug(e)
                game_id = None

            if game_id:
                game = Game(game_id)
                game.launch()
            else:
                ErrorDialog(message=_("Could not retrieve game installer."),
                            parent=self.window)
            return True
        if not game.slug:
            raise ValueError("Invalid game passed: %s" % game)
            # return True
        installers = get_installers(game_slug=game.slug)
        if installers:
            self.show_installer_window(installers)
        else:
            logger.debug("Should generate automagical installer here but....")
            logger.debug("Wait? how did you get here?")
        return True
Beispiel #2
0
 def on_game_install(self, game):
     """Request installation of a game"""
     installers = get_installers(game_slug=game.slug)
     if installers:
         self.show_installer_window(installers)
     else:
         logger.error("TODO: Generate autoinstaller")
Beispiel #3
0
    def on_game_install(self, game):
        """Request installation of a game"""
        if game.service and game.service != "lutris":
            service = get_enabled_services()[game.service]()
            db_game = ServiceGameCollection.get_game(service.id, game.appid)

            try:
                game_id = service.install(db_game)
            except ValueError as e:
                logger.debug(e)
                game_id = None

            if game_id:
                game = Game(game_id)
                game.launch()
            return True
        if not game.slug:
            raise ValueError("Invalid game passed: %s" % game)
            # return True
        installers = get_installers(game_slug=game.slug)
        if installers:
            self.show_installer_window(installers)
        else:
            ErrorDialog(_("There is no installer available for %s.") %
                        game.name,
                        parent=self.window)
        return True
Beispiel #4
0
 def install_from_script(self):
     """Install from a YAML file"""
     script_dlg = FileDialog(_("Select a Lutris installer"))
     if script_dlg.filename:
         installers = get_installers(installer_file=script_dlg.filename)
         application = Gio.Application.get_default()
         application.show_installer_window(installers)
     self.destroy()
Beispiel #5
0
 def install(self, db_game):
     egs_game = get_game_by_field(self.client_installer, "installer_slug")
     application = Gio.Application.get_default()
     if not egs_game or not egs_game["installed"]:
         installers = get_installers(game_slug=self.client_installer, )
         application.show_installer_window(installers)
     else:
         application.show_installer_window(
             [self.generate_installer(db_game, egs_game)],
             service=self,
             appid=db_game["appid"])
Beispiel #6
0
 def install(self, db_game):
     origin_game = get_game_by_field(self.client_installer, "slug")
     application = Gio.Application.get_default()
     if not origin_game or not origin_game["installed"]:
         logger.warning("Installing the Origin client")
         installers = get_installers(game_slug=self.client_installer)
         application.show_installer_window(installers)
     else:
         application.show_installer_window(
             [self.generate_installer(db_game, origin_game)],
             service=self,
             appid=db_game["appid"])
Beispiel #7
0
 def install(self, db_game):
     """Install a game or Ubisoft Connect if not already installed"""
     ubisoft_connect = get_game_by_field(self.client_installer, "slug")
     application = Gio.Application.get_default()
     if not ubisoft_connect or not ubisoft_connect["installed"]:
         logger.warning("Ubisoft Connect (%s) not installed",
                        self.client_installer)
         installers = get_installers(game_slug=self.client_installer)
         application.show_installer_window(installers)
     else:
         application.show_installer_window(
             [self.generate_installer(db_game, ubisoft_connect)],
             service=self,
             appid=db_game["appid"])
Beispiel #8
0
    def on_game_install(self, game):
        """Request installation of a game"""
        if game.service:
            service = get_services()[game.service]()
            db_game = ServiceGameCollection.get_game(service.id, game.appid)
            service.install(db_game)
            return True

        installers = get_installers(game_slug=game.slug)
        if installers:
            self.show_installer_window(installers)
        else:
            logger.debug("Should generate automagical installer here but....")
            logger.debug("Wait? how did you get here?")
        return True
Beispiel #9
0
 def on_game_install(self, game):
     """Request installation of a game"""
     if game.service:
         service = get_enabled_services()[game.service]()
         db_game = ServiceGameCollection.get_game(service.id, game.appid)
         game_id = service.install(db_game)
         if game_id:
             game = Game(game_id)
             game.launch()
         return True
     if not game.slug:
         raise ValueError("Invalid game passed: %s" % game)
         # return True
     installers = get_installers(game_slug=game.slug)
     if installers:
         self.show_installer_window(installers)
     else:
         logger.debug("Should generate automagical installer here but....")
         logger.debug("Wait? how did you get here?")
     return True
 def on_game_install(self, game):
     """Request installation of a game"""
     if game.service:
         service = get_services()[game.service]()
         db_game = ServiceGameCollection.get_game(service.id, game.appid)
         game_id = service.install(db_game)
         if game_id:
             game = Game(game_id)
             game.launch()
         return True
     if not game.slug:
         logger.error("%s doesn't have a slug set, can't query installers",
                      game)
         return True
     installers = get_installers(game_slug=game.slug)
     if installers:
         self.show_installer_window(installers)
     else:
         logger.debug("Should generate automagical installer here but....")
         logger.debug("Wait? how did you get here?")
     return True
Beispiel #11
0
 def install(self, db_game):
     steam_game = get_game_by_field(self.client_installer, "installer_slug")
     if not steam_game:
         installers = get_installers(game_slug=self.client_installer, )
     else:
         installers = [self.generate_installer(db_game, steam_game)]
         appid = db_game["appid"]
         db_games = get_games(filters={
             "service_id": appid,
             "installed": "1",
             "service": self.id
         })
         existing_game = self.match_existing_game(db_games, appid)
         if existing_game:
             logger.debug("Found steam game: %s", existing_game)
             game = Game(existing_game.id)
             game.save()
             return
     application = Gio.Application.get_default()
     application.show_installer_window(installers,
                                       service=self,
                                       appid=appid)
Beispiel #12
0
    def do_command_line(self, command_line):  # noqa: C901  # pylint: disable=arguments-differ
        # pylint: disable=too-many-locals,too-many-return-statements,too-many-branches
        # pylint: disable=too-many-statements
        # TODO: split into multiple methods to reduce complexity (35)
        options = command_line.get_options_dict()

        # Use stdout to output logs, only if no command line argument is
        # provided
        argc = len(sys.argv) - 1
        if "-d" in sys.argv or "--debug" in sys.argv:
            argc -= 1
        if not argc:
            # Switch back the log output to stderr (the default in Python)
            # to avoid messing with any output from command line options.

            # Use when targetting Python 3.7 minimum
            # console_handler.setStream(sys.stderr)

            # Until then...
            logger.removeHandler(log.console_handler)
            log.console_handler = logging.StreamHandler(stream=sys.stdout)
            log.console_handler.setFormatter(log.SIMPLE_FORMATTER)
            logger.addHandler(log.console_handler)

        # Set up logger
        if options.contains("debug"):
            log.console_handler.setFormatter(log.DEBUG_FORMATTER)
            logger.setLevel(logging.DEBUG)

        # Text only commands

        # Print Lutris version and exit
        if options.contains("version"):
            executable_name = os.path.basename(sys.argv[0])
            print(executable_name + "-" + settings.VERSION)
            logger.setLevel(logging.NOTSET)
            return 0

        logger.info("Lutris %s", settings.VERSION)
        migrate()
        run_all_checks()
        AsyncCall(init_dxvk_versions, None)

        # List game
        if options.contains("list-games"):
            game_list = games_db.get_games()
            if options.contains("installed"):
                game_list = [game for game in game_list if game["installed"]]
            if options.contains("json"):
                self.print_game_json(command_line, game_list)
            else:
                self.print_game_list(command_line, game_list)
            return 0
        # List Steam games
        if options.contains("list-steam-games"):
            self.print_steam_list(command_line)
            return 0
        # List Steam folders
        if options.contains("list-steam-folders"):
            self.print_steam_folders(command_line)
            return 0

        # Execute command in Lutris context
        if options.contains("exec"):
            command = options.lookup_value("exec").get_string()
            self.execute_command(command)
            return 0

        if options.contains("submit-issue"):
            IssueReportWindow(application=self)
            return 0

        try:
            url = options.lookup_value(GLib.OPTION_REMAINING)
            installer_info = self.get_lutris_action(url)
        except ValueError:
            self._print(command_line, _("%s is not a valid URI") % url.get_strv())
            return 1

        game_slug = installer_info["game_slug"]
        action = installer_info["action"]

        if options.contains("output-script"):
            action = "write-script"

        revision = installer_info["revision"]

        installer_file = None
        if options.contains("install"):
            installer_file = options.lookup_value("install").get_string()
            if installer_file.startswith(("http:", "https:")):
                try:
                    request = Request(installer_file).get()
                except HTTPError:
                    self._print(command_line, _("Failed to download %s") % installer_file)
                    return 1
                try:
                    headers = dict(request.response_headers)
                    file_name = headers["Content-Disposition"].split("=", 1)[-1]
                except (KeyError, IndexError):
                    file_name = os.path.basename(installer_file)
                file_path = os.path.join(tempfile.gettempdir(), file_name)
                self._print(command_line, _("download {url} to {file} started").format(
                    url=installer_file, file=file_path))
                with open(file_path, 'wb') as dest_file:
                    dest_file.write(request.content)
                installer_file = file_path
                action = "install"
            else:
                installer_file = os.path.abspath(installer_file)
                action = "install"

            if not os.path.isfile(installer_file):
                self._print(command_line, _("No such file: %s") % installer_file)
                return 1

        db_game = None
        if game_slug:
            if action == "rungameid":
                # Force db_game to use game id
                self.run_in_background = True
                db_game = games_db.get_game_by_field(game_slug, "id")
            elif action == "rungame":
                # Force db_game to use game slug
                self.run_in_background = True
                db_game = games_db.get_game_by_field(game_slug, "slug")
            elif action == "install":
                # Installers can use game or installer slugs
                self.run_in_background = True
                db_game = games_db.get_game_by_field(game_slug, "slug") \
                    or games_db.get_game_by_field(game_slug, "installer_slug")
            else:
                # Dazed and confused, try anything that might works
                db_game = (
                    games_db.get_game_by_field(game_slug, "id")
                    or games_db.get_game_by_field(game_slug, "slug")
                    or games_db.get_game_by_field(game_slug, "installer_slug")
                )

        # If reinstall flag is passed, force the action to install
        if options.contains("reinstall"):
            action = "install"

        if action == "write-script":
            if not db_game or not db_game["id"]:
                logger.warning("No game provided to generate the script")
                return 1
            self.generate_script(db_game, options.lookup_value("output-script").get_string())
            return 0

        # Graphical commands
        self.activate()
        self.set_tray_icon()

        if not action:
            if db_game and db_game["installed"]:
                # Game found but no action provided, ask what to do
                dlg = InstallOrPlayDialog(db_game["name"])
                if not dlg.action_confirmed:
                    action = None
                elif dlg.action == "play":
                    action = "rungame"
                elif dlg.action == "install":
                    action = "install"
            elif game_slug or installer_file:
                # No game found, default to install if a game_slug or
                # installer_file is provided
                action = "install"
        if action == "install":
            installers = get_installers(
                game_slug=game_slug,
                installer_file=installer_file,
                revision=revision,
            )
            if installers:
                self.show_installer_window(installers)

        elif action in ("rungame", "rungameid"):
            if not db_game or not db_game["id"]:
                logger.warning("No game found in library")
                if not self.window.is_visible():
                    self.do_shutdown()
                return 0
            game = Game(db_game["id"])
            self.on_game_launch(game)
        return 0
Beispiel #13
0
 def on_install_clicked(self, *_args):
     """Install a game"""
     # Install the currently selected game in the UI
     installers = get_installers(game_slug=self.game.slug)
     self.application.show_installer_window(installers=installers)
Beispiel #14
0
 def _on_game_selected(self, listbox, row):
     game_slug = row.api_info["slug"]
     installers = get_installers(game_slug=game_slug)
     application = Gio.Application.get_default()
     application.show_installer_window(installers)
     self.destroy()