コード例 #1
0
ファイル: wine.py プロジェクト: l10n-tw/lutris
def open_wine_terminal(terminal, wine_path, prefix, env):
    aliases = {
        "wine": wine_path,
        "winecfg": wine_path + "cfg",
        "wineserver": wine_path + "server",
        "wineboot": wine_path + "boot",
    }
    env["WINEPREFIX"] = prefix
    shell_command = get_shell_command(prefix, env, aliases)
    terminal = terminal or linux.get_default_terminal()
    system.execute([linux.get_default_terminal(), "-e", shell_command])
コード例 #2
0
 def get_terminal(self):
     """Return the terminal used to run the game into or None if the game is not run from a terminal.
     Remember that only games using text mode should use the terminal.
     """
     if self.runner.system_config.get("terminal"):
         terminal = self.runner.system_config.get("terminal_app", linux.get_default_terminal())
         if terminal and not system.find_executable(terminal):
             raise GameConfigError(_("The selected terminal application could not be launched:\n%s") % terminal)
         return terminal
コード例 #3
0
ファイル: sysoptions.py プロジェクト: muzena/lutris
     "help":
     _("Enable a terminal for text-based games. "
       "Only useful for ASCII based games. May cause issues with graphical games."
       ),
 },
 {
     "option":
     "terminal_app",
     "label":
     _("Text based games emulator"),
     "type":
     "choice_with_entry",
     "choices":
     linux.get_terminal_apps,
     "default":
     linux.get_default_terminal(),
     "advanced":
     True,
     "help":
     _("The terminal emulator used with the CLI mode. "
       "Choose from the list of detected terminal apps or enter "
       "the terminal's command or path."),
 },
 {
     "option": "env",
     "type": "mapping",
     "label": _("Environment variables"),
     "help": _("Environment variables loaded at run time"),
 },
 {
     "option": "antimicro_config",
コード例 #4
0
ファイル: commands.py プロジェクト: meskobalazs/lutris
    def execute(self, data):
        """Run an executable file."""
        args = []
        terminal = None
        working_dir = None
        env = {}
        if isinstance(data, dict):
            self._check_required_params([("file", "command")], data, "execute")
            if "command" in data and "file" in data:
                raise ScriptingError(
                    "Parameters file and command can't be used "
                    "at the same time for the execute command",
                    data,
                )
            file_ref = data.get("file", "")
            command = data.get("command", "")
            args_string = data.get("args", "")
            for arg in shlex.split(args_string):
                args.append(self._substitute(arg))
            terminal = data.get("terminal")
            working_dir = data.get("working_dir")
            if not data.get("disable_runtime"):
                # Possibly need to handle prefer_system_libs here
                env.update(runtime.get_env())

            # Loading environment variables set in the script
            env.update(self.script_env)

            # Environment variables can also be passed to the execute command
            local_env = data.get("env") or {}
            env.update({
                key: self._substitute(value)
                for key, value in local_env.items()
            })
            include_processes = shlex.split(data.get("include_processes", ""))
            exclude_processes = shlex.split(data.get("exclude_processes", ""))
        elif isinstance(data, str):
            command = data
            include_processes = []
            exclude_processes = []
        else:
            raise ScriptingError("No parameters supplied to execute command.",
                                 data)

        if command:
            file_ref = "bash"
            args = ["-c", self._get_file(command.strip())]
            include_processes.append("bash")
        else:
            # Determine whether 'file' value is a file id or a path
            file_ref = self._get_file(file_ref)
        if system.path_exists(file_ref) and not system.is_executable(file_ref):
            logger.warning("Making %s executable", file_ref)
            system.make_executable(file_ref)
        exec_path = system.find_executable(file_ref)
        if not exec_path:
            raise ScriptingError("Unable to find executable %s" % file_ref)

        if terminal:
            terminal = linux.get_default_terminal()

        if not working_dir or not os.path.exists(working_dir):
            working_dir = self.target_path

        command = MonitoredCommand(
            [exec_path] + args,
            env=env,
            term=terminal,
            cwd=working_dir,
            include_processes=include_processes,
            exclude_processes=exclude_processes,
        )
        command.start()
        GLib.idle_add(self.parent.attach_logger, command)
        self.heartbeat = GLib.timeout_add(1000, self._monitor_task, command)
        return "STOP"