Beispiel #1
0
    def on_downloaded(self, path):
        """Actions taken once a runtime is downloaded

        Arguments:
            path (str): local path to the runtime archive
        """
        stats = os.stat(path)
        if not stats.st_size:
            logger.error("Download failed: file %s is empty, Deleting file.",
                         path)
            os.unlink(path)
            self.updater.notify_finish(self)
            return False
        directory, _filename = os.path.split(path)

        # Delete the existing runtime path
        initial_path = os.path.join(directory, self.name)
        system.remove_folder(initial_path)

        # Extract the runtime archive
        jobs.AsyncCall(extract_archive,
                       self.on_extracted,
                       path,
                       settings.RUNTIME_DIR,
                       merge_single=False)
        return False
Beispiel #2
0
 def stop(self):
     if self.runner.system_config.get('xboxdrv'):
         logger.debug("Stopping xboxdrv")
         self.xboxdrv_thread.stop()
     if self.game_thread:
         jobs.AsyncCall(self.game_thread.stop, None, killall=self.runner.killall_on_exit())
     self.state = self.STATE_STOPPED
Beispiel #3
0
 def on_runner_downloaded(self, row):
     version = row[0]
     architecture = row[1]
     logger.debug("Runner %s for %s has finished downloading", version,
                  architecture)
     src = self.get_dest_path(row)
     dst = self.get_runner_path(version, architecture)
     jobs.AsyncCall(self.extract, self.on_extracted, src, dst, row)
Beispiel #4
0
 def on_runner_downloaded(self, row):
     """Handler called when a runner version is downloaded"""
     version = row[self.COL_VER]
     architecture = row[self.COL_ARCH]
     logger.debug("Runner %s for %s has finished downloading", version, architecture)
     src = self.get_dest_path(row)
     dst = self.get_runner_path(version, architecture)
     jobs.AsyncCall(self.extract, self.on_extracted, src, dst, row)
Beispiel #5
0
 def get_scripts(self):
     if system.path_exists(self.installer_file):
         # local script
         self.on_scripts_obtained(
             interpreter.read_script(self.installer_file))
     else:
         jobs.AsyncCall(interpreter.fetch_script, self.on_scripts_obtained,
                        self.game_slug, self.revision)
Beispiel #6
0
 def get_scripts(self):
     if system.path_exists(self.installer_file):
         # local script
         logger.debug("Opening script: %s", self.installer_file)
         scripts = yaml.safe_load(open(self.installer_file, 'r').read())
         self.on_scripts_obtained(scripts)
     else:
         jobs.AsyncCall(interpreter.fetch_script, self.on_scripts_obtained,
                        self.game_slug, self.revision)
Beispiel #7
0
 def get_scripts(self):
     if os.path.isfile(self.game_ref):
         # local script
         logger.debug("Opening script: %s", self.game_ref)
         scripts = yaml.safe_load(open(self.game_ref, 'r').read())
         self.on_scripts_obtained(scripts)
     else:
         jobs.AsyncCall(interpreter.fetch_script, self.on_scripts_obtained,
                        self.game_ref)
Beispiel #8
0
 def on_downloaded(self, path):
     dir, filename = os.path.split(path)
     folder = os.path.join(dir, filename[:filename.find('.')])
     system.remove_folder(folder)
     jobs.AsyncCall(extract_archive,
                    self.on_extracted,
                    path,
                    RUNTIME_DIR,
                    merge_single=False)
Beispiel #9
0
 def on_runner_downloaded(self, row):
     """Handler called when a runner version is downloaded"""
     runner = row.runner
     version = runner[self.COL_VER]
     architecture = runner[self.COL_ARCH]
     logger.debug("Runner %s for %s has finished downloading", version, architecture)
     src = self.get_dest_path(runner)
     dst = self.get_runner_path(version, architecture)
     GLib.timeout_add(100, self.progress_pulse, row)
     jobs.AsyncCall(self.extract, self.on_extracted, src, dst, row)
Beispiel #10
0
 def start(self):
     """Start download job."""
     logger.debug("Starting download of:\n %s", self.url)
     self.state = self.DOWNLOADING
     self.last_check_time = get_time()
     if self.overwrite and os.path.isfile(self.dest):
         os.remove(self.dest)
     self.file_pointer = open(self.dest, "wb")
     self.thread = jobs.AsyncCall(self.async_download, self.on_done)
     self.stop_request = self.thread.stop_request
Beispiel #11
0
 def start(self):
     """Start download job."""
     logger.debug("⬇ %s", self.url)
     self.state = self.DOWNLOADING
     self.last_check_time = get_time()
     if self.overwrite and os.path.isfile(self.dest):
         os.remove(self.dest)
     self.file_pointer = open(self.dest, "wb")  # pylint: disable=consider-using-with
     self.thread = jobs.AsyncCall(self.async_download, self.download_cb)
     self.stop_request = self.thread.stop_request
Beispiel #12
0
    def stop(self):
        """Stops the game"""
        if self.state == self.STATE_STOPPED:
            logger.debug("Game already stopped")
            return

        logger.info("Stopping %s", self)

        if self.game_thread:
            jobs.AsyncCall(self.game_thread.stop, None)
        self.stop_game()
Beispiel #13
0
 def get_scripts(self, local_script=False):
     if local_script:
         self.on_scripts_obtained(
             interpreter.read_script(self.installer_file))
     else:
         jobs.AsyncCall(
             interpreter.fetch_script,
             self.on_scripts_obtained,
             self.game_slug,
             self.revision,
         )
Beispiel #14
0
    def play(self):
        """Launch the game."""
        if not self.runner:
            dialogs.ErrorDialog(_("Invalid game configuration: Missing runner"))
            return

        if not self.is_launchable():
            logger.error("Game is not launchable")
            return
        self.state = self.STATE_LAUNCHING
        self.emit("game-start")
        jobs.AsyncCall(self.runner.prelaunch, self.configure_game)
Beispiel #15
0
    def stop(self):
        """Stops the game"""
        if self.state == self.STATE_STOPPED:
            logger.debug("Game already stopped")
            return

        logger.info("Stopping %s", self)
        if self.runner.system_config.get("xboxdrv"):
            logger.debug("Stopping xboxdrv")
            self.xboxdrv_thread.stop()
        if self.game_thread:
            jobs.AsyncCall(self.game_thread.stop, None)
        self.stop_game()
Beispiel #16
0
    def play(self):
        """Launch the game."""
        if not self.runner:
            dialogs.ErrorDialog("Invalid game configuration: Missing runner")
            self.state = self.STATE_STOPPED
            return

        if not self.prelaunch():
            self.state = self.STATE_STOPPED
            return

        if hasattr(self.runner, 'prelaunch'):
            jobs.AsyncCall(self.runner.prelaunch, self.do_play)
        else:
            self.do_play(True)
Beispiel #17
0
    def play(self):
        """Launch the game."""
        if not self.runner:
            dialogs.ErrorDialog("Invalid game configuration: Missing runner")
            self.state = self.STATE_STOPPED
            self.emit("game-stop")
            return

        if not self.is_launchable():
            self.state = self.STATE_STOPPED
            self.emit("game-stop")
            return

        self.emit("game-start")
        jobs.AsyncCall(self.runner.prelaunch, self.configure_game)
Beispiel #18
0
    def on_downloaded(self, path):
        """Actions taken once a runtime is downloaded

        Arguments:
            path (str): local path to the runtime archive
        """
        directory, _filename = os.path.split(path)

        # Delete the existing runtime path
        initial_path = os.path.join(directory, self.name)
        system.remove_folder(initial_path)

        # Extract the runtime archive
        jobs.AsyncCall(extract_archive, self.on_extracted, path, RUNTIME_DIR, merge_single=False)
        return False
Beispiel #19
0
    def launch(self):
        """Request launching a game. The game may not be installed yet."""
        if not self.is_launchable():
            logger.error("Game is not launchable")
            return

        self.load_config()  # Reload the config before launching it.

        if str(self.id) in LOG_BUFFERS:  # Reset game logs on each launch
            log_buffer = LOG_BUFFERS[str(self.id)]
            log_buffer.delete(log_buffer.get_start_iter(), log_buffer.get_end_iter())

        self.state = self.STATE_LAUNCHING
        self.prelaunch_pids = system.get_running_pid_list()
        self.emit("game-start")
        jobs.AsyncCall(self.runner.prelaunch, self.configure_game)
Beispiel #20
0
 def launch(self):
     """Request launching a game. The game may not be installed yet."""
     if not self.is_installed:
         self.emit("game-install")
         return
     wait_for_dxvk_init()
     self.load_config()  # Reload the config before launching it.
     if not self.runner:
         dialogs.ErrorDialog(_("Invalid game configuration: Missing runner"))
         return
     if not self.is_launchable():
         logger.error("Game is not launchable")
         return
     self.state = self.STATE_LAUNCHING
     self.emit("game-start")
     jobs.AsyncCall(self.runner.prelaunch, self.configure_game)
Beispiel #21
0
    def stop(self):
        if self.state == self.STATE_STOPPED:
            logger.debug("Game already stopped")
            return
        if not self.runner:
            self.error("No game actually running, this shouldn't happen")
            return

        logger.info("Stopping %s", self)
        if self.runner.system_config.get("xboxdrv"):
            logger.debug("Stopping xboxdrv")
            self.xboxdrv_thread.stop()
        if self.game_thread:
            jobs.AsyncCall(self.game_thread.stop, None)
        self.state = self.STATE_STOPPED
        if not self.timer.finished:
            self.timer.end()
            self.playtime = self.timer.duration + self.playtime
Beispiel #22
0
    def launch(self):
        """Request launching a game. The game may not be installed yet."""
        if not self.is_installed:
            raise RuntimeError("Tried to launch a game that isn't installed")
        self.load_config()  # Reload the config before launching it.

        if str(self.id) in LOG_BUFFERS:  # Reset game logs on each launch
            LOG_BUFFERS.pop(str(self.id))

        if not self.runner:
            dialogs.ErrorDialog(_("Invalid game configuration: Missing runner"))
            return
        if not self.is_launchable():
            logger.error("Game is not launchable")
            return
        self.state = self.STATE_LAUNCHING
        self.prelaunch_pids = system.get_running_pid_list()
        self.emit("game-start")
        jobs.AsyncCall(self.runner.prelaunch, self.configure_game)
Beispiel #23
0
    def __init__(self, title, parent, runner):
        super().__init__(title, parent, 0)
        self.add_buttons(_("_OK"), Gtk.ButtonsType.OK)
        self.runner = runner
        self.runner_info = {}
        self.installing = {}
        self.set_default_size(640, 480)

        self.renderer_progress = Gtk.CellRendererProgress()

        label = Gtk.Label.new(_("Waiting for response from %s") % (settings.SITE_URL))
        self.vbox.pack_start(label, False, False, 18)

        spinner = Gtk.Spinner(visible=True)
        spinner.start()
        self.vbox.pack_start(spinner, False, False, 18)

        self.show_all()

        self.runner_store = Gtk.ListStore(str, str, str, bool, int, str)
        jobs.AsyncCall(api.get_runners, self.display_all_versions, self.runner)
Beispiel #24
0
    def __init__(self, title, parent, runner):
        super().__init__(title, parent, 0)
        self.add_buttons(_("_OK"), Gtk.ButtonsType.OK)
        self.runner = runner
        self.runner_info = {}
        self.installing = {}
        self.set_default_size(640, 480)
        self.runners = []
        self.listbox = None

        label = Gtk.Label.new(_("Waiting for response from %s") % settings.SITE_URL)
        self.vbox.pack_start(label, False, False, 18)

        spinner = Gtk.Spinner(visible=True)
        spinner.start()
        self.vbox.pack_start(spinner, False, False, 18)

        self.show_all()

        self.runner_store = Gtk.ListStore(str, str, str, bool, int, int)
        jobs.AsyncCall(api.get_runners, self.runner_fetch_cb, self.runner)
Beispiel #25
0
    def __init__(self, title, parent, runner):
        super().__init__(title, parent, 0, ("_OK", Gtk.ResponseType.OK))
        width, height = (512, 480)
        self.dialog_size = (width, height)
        self.set_default_size(width, height)

        self.runner = runner

        self.label = Gtk.Label("Waiting for response from %s" %
                               (settings.SITE_URL))
        self.vbox.pack_start(self.label, False, False, 18)

        # Display a wait icon.
        self.spinner = Gtk.Spinner()
        self.vbox.pack_start(self.spinner, False, False, 18)
        self.spinner.show()
        self.spinner.start()

        self.show_all()

        jobs.AsyncCall(api.get_runners, self.display_all_versions, self.runner)
Beispiel #26
0
    def play(self):
        """Launch the game."""
        if not self.runner:
            dialogs.ErrorDialog("Invalid game configuration: Missing runner")
            self.state = self.STATE_STOPPED
            return

        if not self.prelaunch():
            self.state = self.STATE_STOPPED
            return

        if hasattr(self.runner, "prelaunch"):
            logger.debug("Prelaunching %s", self.runner)
            try:
                jobs.AsyncCall(self.runner.prelaunch, self.configure_game)
            except Exception as ex:
                logger.error(ex)
                raise

        else:
            self.configure_game(True)
Beispiel #27
0
 def stop(self):
     self.state = self.STATE_STOPPED
     if self.runner.system_config.get('xboxdrv'):
         self.xboxdrv_thread.stop()
     if self.game_thread:
         jobs.AsyncCall(self.game_thread.stop, None, killall=True)
 def on_runner_downloaded(self, row):
     version = row[0]
     architecture = row[1]
     src = self.get_dest_path(row)
     dst = self.get_runner_path(version, architecture)
     jobs.AsyncCall(self.extract, self.on_extracted, src, dst, row)
Beispiel #29
0
    def __init__(
        self,
        game_slug=None,
        installer_file=None,
        revision=None,
        parent=None,
        application=None,
    ):
        super().__init__(application=application)

        self.install_in_progress = False
        self.interpreter = None
        self.parent = parent
        self.game_slug = game_slug
        self.revision = revision
        self.desktop_shortcut_box = None
        self.menu_shortcut_box = None

        self.log_buffer = None
        self.log_textview = None

        self.title_label = InstallerLabel()
        self.title_label.set_selectable(False)
        self.vbox.add(self.title_label)

        self.status_label = InstallerLabel()
        self.status_label.set_max_width_chars(80)
        self.status_label.set_property("wrap", True)
        self.status_label.set_selectable(True)
        self.vbox.add(self.status_label)

        self.widget_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.vbox.pack_start(self.widget_box, True, True, 0)

        self.vbox.add(Gtk.HSeparator())

        self.action_buttons = Gtk.Box(spacing=6)
        action_buttons_alignment = Gtk.Alignment.new(1, 0, 0, 0)
        action_buttons_alignment.add(self.action_buttons)
        self.vbox.pack_start(action_buttons_alignment, False, True, 0)

        self.manual_button = self.add_button(_("Configure m_anually"),
                                             self.on_manual_clicked)
        self.cancel_button = self.add_button(
            _("C_ancel"),
            self.cancel_installation,
            tooltip=_("Abort and revert the installation"))
        self.eject_button = self.add_button(_("_Eject"), self.on_eject_clicked)
        self.source_button = self.add_button(_("_View source"),
                                             self.on_source_clicked)
        self.install_button = self.add_button(_("_Install"),
                                              self.on_install_clicked)
        self.continue_button = self.add_button(_("_Continue"))
        self.play_button = self.add_button(_("_Launch"), self.launch_game)
        self.close_button = self.add_button(_("_Close"), self.on_destroy)

        self.continue_handler = None

        # check if installer is local or online
        if system.path_exists(installer_file):
            self.on_scripts_obtained(interpreter.read_script(installer_file))
        else:
            self.title_label.set_markup(
                _("Waiting for response from %s") % (settings.SITE_URL))
            self.add_spinner()
            self.widget_box.show()
            self.title_label.show()
            jobs.AsyncCall(
                interpreter.fetch_script,
                self.on_scripts_obtained,
                self.game_slug,
                self.revision,
            )
        self.present()