示例#1
0
    def task(self, data):
        """ This action triggers a task within a runner.
            The 'name' parameter is mandatory. If 'args' is provided it will be
            passed to the runner task.
        """
        task_name = data.pop('name')
        if not task_name:
            raise ScriptingError("Missing required task name", data)
        if '.' in task_name:
            # Run a task from a different runner than the one for this installer
            runner_name, task_name = task_name.split('.')
        else:
            runner_name = self.script["runner"]

        # Check that runner is installed or install it
        runner = import_runner(runner_name)()
        if not runner.is_installed():
            Gdk.threads_init()
            Gdk.threads_enter()
            runner.install()
            Gdk.threads_leave()

        for key in data:
            data[key] = self._substitute(data[key])
        task = import_task(runner_name, task_name)
        task(**data)
示例#2
0
    def task(self, data):
        """ This action triggers a task within a runner.
            The 'name' parameter is mandatory. If 'args' is provided it will be
            passed to the runner task.
        """
        task_name = data.pop('name')
        if not task_name:
            raise ScriptingError("Missing required task name", data)
        if '.' in task_name:
            # Run a task from a different runner than the one for this installer
            runner_name, task_name = task_name.split('.')
        else:
            runner_name = self.script["runner"]

        # Check that runner is installed or install it
        runner = import_runner(runner_name)()
        if not runner.is_installed():
            Gdk.threads_init()
            Gdk.threads_enter()
            runner.install()
            Gdk.threads_leave()

        for key in data:
            data[key] = self._substitute(data[key])
        task = import_task(runner_name, task_name)
        task(**data)
示例#3
0
    def task(self, data):
        """Directive triggering another function specific to a runner.

        The 'name' parameter is mandatory. If 'args' is provided it will be
        passed to the runner task.
        """
        self._check_required_params('name', data, 'task')
        if self.parent:
            GLib.idle_add(self.parent.cancel_button.set_sensitive, False)
        runner_name, task_name = self._get_task_runner_and_name(data.pop('name'))

        # Check/install Wine runner at version specified in the script
        # TODO : move this, the runner should be installed before the install
        # starts
        wine_version = None
        if runner_name == 'wine':
            wine_version = self._get_runner_version()

        if wine_version and task_name == 'wineexec':
            data['wine_path'] = wine.get_wine_version_exe(wine_version)

        for key in data:
            data[key] = self._substitute(data[key])

        if runner_name in ['wine', 'winesteam'] and 'prefix' not in data:
            data['prefix'] = self.target_path

        task = import_task(runner_name, task_name)
        thread = task(**data)
        GLib.idle_add(self.parent.cancel_button.set_sensitive, True)
        if isinstance(thread, LutrisThread):
            # Monitor thread and continue when task has executed
            self.heartbeat = GLib.timeout_add(1000, self._monitor_task, thread)
            return 'STOP'
示例#4
0
    def task(self, data):
        """Directive triggering another function specific to a runner.

        The 'name' parameter is mandatory. If 'args' is provided it will be
        passed to the runner task.
        """
        self._check_required_params("name", data, "task")
        if self.parent:
            GLib.idle_add(self.parent.cancel_button.set_sensitive, False)
        runner_name, task_name = self._get_task_runner_and_name(
            data.pop("name"))

        wine_version = None

        if runner_name.startswith("wine"):
            wine_version = self._get_runner_version()
            if wine_version:
                data["wine_path"] = get_wine_version_exe(wine_version)
            data["prefix"] = data.get("prefix") \
                or self.installer.script.get("game", {}).get("prefix") \
                or "$GAMEDIR"
            data["arch"] = data.get("arch") \
                or self.installer.script.get("game", {}).get("arch") \
                or WINE_DEFAULT_ARCH
            if task_name == "wineexec" and self.script_env:
                data["env"] = self.script_env
            else:
                data["env"] = {}

            data["env"]["WINEDLLOVERRIDES"] = (
                "winemenubuilder=d;" +
                data["env"].get("WINEDLLOVERRIDES", "")).strip(";")

        for key in data:
            value = data[key]
            if isinstance(value, dict):
                for inner_key in value:
                    value[inner_key] = self._substitute(value[inner_key])
            elif isinstance(value, list):
                for index, elem in enumerate(value):
                    value[index] = self._substitute(elem)
            else:
                value = self._substitute(data[key])
            data[key] = value

        task = import_task(runner_name, task_name)
        command = task(**data)
        GLib.idle_add(self.parent.cancel_button.set_sensitive, True)
        if isinstance(command, MonitoredCommand):
            # Monitor thread and continue when task has executed
            GLib.idle_add(self.parent.attach_logger, command)
            self.heartbeat = GLib.timeout_add(1000, self._monitor_task,
                                              command)
            return "STOP"
        return None
示例#5
0
    def task(self, data):
        """Directive triggering another function specific to a runner.

        The 'name' parameter is mandatory. If 'args' is provided it will be
        passed to the runner task.
        """
        self._check_required_params("name", data, "task")
        if self.parent:
            GLib.idle_add(self.parent.cancel_button.set_sensitive, False)
        runner_name, task_name = self._get_task_runner_and_name(
            data.pop("name"))

        # Accept return codes other than 0
        if "return_code" in data:
            return_code = data.pop("return_code")
        else:
            return_code = "0"

        if runner_name.startswith("wine"):
            wine_path = self.get_wine_path()
            if wine_path:
                data["wine_path"] = wine_path
            data["prefix"] = data.get("prefix") \
                or self.installer.script.get("game", {}).get("prefix") \
                or "$GAMEDIR"
            data["arch"] = data.get("arch") \
                or self.installer.script.get("game", {}).get("arch") \
                or WINE_DEFAULT_ARCH
            if task_name == "wineexec":
                data["env"] = self.script_env

        for key in data:
            value = data[key]
            if isinstance(value, dict):
                for inner_key in value:
                    value[inner_key] = self._substitute(value[inner_key])
            elif isinstance(value, list):
                for index, elem in enumerate(value):
                    value[index] = self._substitute(elem)
            else:
                value = self._substitute(data[key])
            data[key] = value

        task = import_task(runner_name, task_name)
        command = task(**data)
        if command:
            command.accepted_return_code = return_code
        GLib.idle_add(self.parent.cancel_button.set_sensitive, True)
        if isinstance(command, MonitoredCommand):
            # Monitor thread and continue when task has executed
            GLib.idle_add(self.parent.attach_logger, command)
            self.heartbeat = GLib.timeout_add(1000, self._monitor_task,
                                              command)
            return "STOP"
        return None
示例#6
0
 def task(self, data):
     """ This action triggers a task within a runner.
         The 'name' parameter is mandatory. If 'args' is provided it will be
         passed to the runner task.
     """
     task_name = data.pop('name')
     runner_name = self.script["runner"]
     for key in data:
         data[key] = self._substitute(data[key])
     task = import_task(runner_name, task_name)
     task(**data)
示例#7
0
文件: commands.py 项目: dacp17/lutris
    def task(self, data):
        """Directive triggering another function specific to a runner.

        The 'name' parameter is mandatory. If 'args' is provided it will be
        passed to the runner task.
        """
        self._check_required_params("name", data, "task")
        self.parent.cancel_button.set_sensitive(False)
        task_name = data.pop("name")
        if "." in task_name:
            # Run a task from a different runner
            # than the one for this installer
            runner_name, task_name = task_name.split(".")
        else:
            runner_name = self.script["runner"]
        try:
            runner_class = import_runner(runner_name)
        except InvalidRunner:
            self.parent.cancel_button.set_sensitive(True)
            raise ScriptingError("Invalid runner provided %s", runner_name)

        runner = runner_class()

        # Check/install Wine runner at version specified in the script
        wine_version = None
        if runner_name == "wine" and self.script.get("wine"):
            wine_version = self.script.get("wine").get("version")

            # Old lutris versions used a version + arch tuple, we now include
            # everything in the version.
            # Before that change every wine runner was for i386
            if "-" not in wine_version:
                wine_version += "-i386"

        if wine_version and task_name == "wineexec":
            if not wine.is_version_installed(wine_version):
                Gdk.threads_init()
                Gdk.threads_enter()
                runner.install(wine_version)
                Gdk.threads_leave()
            data["wine_path"] = wine.get_wine_version_exe(wine_version)
        # Check/install other runner
        elif not runner.is_installed():
            Gdk.threads_init()
            Gdk.threads_enter()
            runner.install()
            Gdk.threads_leave()

        for key in data:
            data[key] = self._substitute(data[key])
        task = import_task(runner_name, task_name)
        task(**data)
        self.parent.cancel_button.set_sensitive(True)
示例#8
0
    def task(self, data):
        """ This action triggers a task within a runner.
            The 'name' parameter is mandatory. If 'args' is provided it will be
            passed to the runner task.
        """
        self._check_required_params('name', data, 'task')
        task_name = data.pop('name')
        if '.' in task_name:
            # Run a task from a different runner than the one for this installer
            runner_name, task_name = task_name.split('.')
        else:
            runner_name = self.script["runner"]
        try:
            runner_class = import_runner(runner_name)
        except InvalidRunner:
            raise ScriptingError('Invalid runner provided %s', runner_name)

        runner = runner_class()

        # Check/install Wine runner at version specified in the script
        wine_version = None
        if runner_name == 'wine' and self.script.get('wine'):
            wine_version = self.script.get('wine').get('version')

            # Old lutris versions used a version + arch tuple, we now include
            # everything in the version.
            # Before that change every wine runner was for i386
            if '-' not in wine_version:
                wine_version += '-i386'

        if wine_version and task_name == 'wineexec':
            if not wine.is_version_installed(wine_version):
                Gdk.threads_init()
                Gdk.threads_enter()
                runner.install(wine_version)
                Gdk.threads_leave()
            data['wine_path'] = wine.get_wine_version_exe(wine_version)
        # Check/install other runner
        elif not runner.is_installed():
            Gdk.threads_init()
            Gdk.threads_enter()
            runner.install()
            Gdk.threads_leave()

        for key in data:
            data[key] = self._substitute(data[key])
        task = import_task(runner_name, task_name)
        task(**data)
示例#9
0
    def task(self, data):
        """Directive triggering another function specific to a runner.

        The 'name' parameter is mandatory. If 'args' is provided it will be
        passed to the runner task.
        """
        self._check_required_params("name", data, "task")
        if self.parent:
            GLib.idle_add(self.parent.cancel_button.set_sensitive, False)
        runner_name, task_name = self._get_task_runner_and_name(data.pop("name"))

        wine_version = None

        if runner_name.startswith("wine"):
            wine_version = self._get_runner_version()
            if wine_version:
                data["wine_path"] = get_wine_version_exe(wine_version)
            data["prefix"] = data.get("prefix") \
                or self.script.get("game", {}).get("prefix") \
                or "$GAMEDIR"
            data["arch"] = data.get("arch") \
                or self.script.get("game", {}).get("arch") \
                or WINE_DEFAULT_ARCH
            if task_name == "wineexec" and self.script_env:
                data["env"] = self.script_env

        for key in data:
            value = data[key]
            if isinstance(value, dict):
                for inner_key in value:
                    value[inner_key] = self._substitute(value[inner_key])
            elif isinstance(value, list):
                for index, elem in enumerate(value):
                    value[index] = self._substitute(elem)
            else:
                value = self._substitute(data[key])
            data[key] = value

        task = import_task(runner_name, task_name)
        thread = task(**data)
        GLib.idle_add(self.parent.cancel_button.set_sensitive, True)
        if isinstance(thread, MonitoredCommand):
            # Monitor thread and continue when task has executed
            GLib.idle_add(self.parent.attach_logger, thread)
            self.heartbeat = GLib.timeout_add(1000, self._monitor_task, thread)
            return "STOP"
        return None
示例#10
0
    def task(self, data):
        """Directive triggering another function specific to a runner.

        The 'name' parameter is mandatory. If 'args' is provided it will be
        passed to the runner task.
        """
        self._check_required_params('name', data, 'task')
        if self.parent:
            GLib.idle_add(self.parent.cancel_button.set_sensitive, False)
        runner_name, task_name = self._get_task_runner_and_name(
            data.pop('name'))

        wine_version = None
        if runner_name == 'wine':
            wine_version = self._get_runner_version()

        if runner_name.startswith('wine'):
            if wine_version:
                data['wine_path'] = get_wine_version_exe(wine_version)

        for key in data:
            value = data[key]
            if isinstance(value, dict):
                for inner_key in value:
                    value[inner_key] = self._substitute(value[inner_key])
            elif isinstance(value, list):
                for index, elem in enumerate(value):
                    value[index] = self._substitute(elem)
            else:
                value = self._substitute(data[key])
            data[key] = value

        if runner_name in ['wine', 'winesteam'] and 'prefix' not in data:
            data['prefix'] = self.target_path

        task = import_task(runner_name, task_name)
        thread = task(**data)
        GLib.idle_add(self.parent.cancel_button.set_sensitive, True)
        if isinstance(thread, LutrisThread):
            # Monitor thread and continue when task has executed
            GLib.idle_add(self.parent.attach_logger, thread)
            self.heartbeat = GLib.timeout_add(1000, self._monitor_task, thread)
            return 'STOP'
        return None
示例#11
0
文件: installer.py 项目: ERIIX/lutris
    def task(self, data):
        """ This action triggers a task within a runner.
            The 'name' parameter is mandatory. If 'args' is provided it will be
            passed to the runner task.
        """
        self._check_required_params('name', data, 'task')
        task_name = data.pop('name')
        if '.' in task_name:
            # Run a task from a different runner than the one for this installer
            runner_name, task_name = task_name.split('.')
        else:
            runner_name = self.script["runner"]
        try:
            runner_class = import_runner(runner_name)
        except InvalidRunner:
            raise ScriptingError('Invalid runner provided %s', runner_name)

        runner = runner_class()

        # Check/install Wine runner at version specified in the script
        wine_version = None
        wine_arch = None
        if runner_name == 'wine' and self.script.get('wine'):
            wine_version = self.script.get('wine').get('version')
            wine_arch = self.script.get('wine').get('arch')
        if wine_version and task_name == 'wineexec':
            if not wine.is_version_installed(wine_version, wine_arch):
                Gdk.threads_init()
                Gdk.threads_enter()
                runner.install(wine_version, wine_arch)
                Gdk.threads_leave()
            data['wine_path'] = wine.get_wine_version_exe(wine_version,
                                                          wine_arch)
        # Check/install other runner
        elif not runner.is_installed():
            Gdk.threads_init()
            Gdk.threads_enter()
            runner.install()
            Gdk.threads_leave()

        for key in data:
            data[key] = self._substitute(data[key])
        task = import_task(runner_name, task_name)
        task(**data)
示例#12
0
    def task(self, data):
        """Directive triggering another function specific to a runner.

        The 'name' parameter is mandatory. If 'args' is provided it will be
        passed to the runner task.
        """
        self._check_required_params('name', data, 'task')
        if self.parent:
            GLib.idle_add(self.parent.cancel_button.set_sensitive, False)
        runner_name, task_name = self._get_task_runner_and_name(data.pop('name'))

        wine_version = None
        if runner_name == 'wine':
            wine_version = self._get_runner_version()

        if runner_name.startswith('wine'):
            if wine_version:
                data['wine_path'] = wine.get_wine_version_exe(wine_version)

        for key in data:
            value = data[key]
            if type(value) is dict:
                for inner_key in value:
                    value[inner_key] = self._substitute(value[inner_key])
            elif type(value) is list:
                for index, elem in enumerate(value):
                    value[index] = self._substitute(elem)
            else:
                value = self._substitute(data[key])
            data[key] = value

        if runner_name in ['wine', 'winesteam'] and 'prefix' not in data:
            data['prefix'] = self.target_path

        task = import_task(runner_name, task_name)
        thread = task(**data)
        GLib.idle_add(self.parent.cancel_button.set_sensitive, True)
        if isinstance(thread, LutrisThread):
            # Monitor thread and continue when task has executed
            GLib.idle_add(self.parent.attach_logger, thread)
            self.heartbeat = GLib.timeout_add(1000, self._monitor_task, thread)
            return 'STOP'