From 8b54e3118fbdb61f23c217e397a2b61204b04628 Mon Sep 17 00:00:00 2001 From: Xodetaetl Date: Wed, 20 Aug 2014 16:02:31 +0200 Subject: [PATCH] Support file paths in the execute task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support entering a file path in the 'file' key of the execute task. And expand variables in the path –> Fixes #70. --- docs/installers.rst | 2 +- lutris/installer.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/installers.rst b/docs/installers.rst index 5f74961ad..c1aa6b709 100644 --- a/docs/installers.rst +++ b/docs/installers.rst @@ -188,7 +188,7 @@ Executing a file ---------------- Execute files with the ``execute`` directive. Use the ``args`` parameter to add -command arguments, and ``file`` to reference a ``file id``. +command arguments, and ``file`` to reference a ``file id`` or a path. Example: diff --git a/lutris/installer.py b/lutris/installer.py index 0be91f268..85939605e 100644 --- a/lutris/installer.py +++ b/lutris/installer.py @@ -443,17 +443,19 @@ class ScriptInterpreter(object): os.popen('chmod +x "%s"' % filename) def execute(self, data): - """Run an executable script""" + """Run an executable file""" if isinstance(data, dict): - exec_id = data['file'] + file_ref = data['file'] args = [self._substitute(arg) for arg in data.get('args', '').split()] else: - exec_id = data + file_ref = data args = [] - exec_path = self._get_file(exec_id) + # Determine whether 'file' value is a file id or a path + exec_path = self._get_file(file_ref) or self._substitute(file_ref) if not exec_path: - raise ScriptingError("Unable to find file %s" % exec_id, exec_id) + raise ScriptingError("Unable to find file %s" % file_ref, + file_ref) if not os.path.exists(exec_path): raise ScriptingError("Unable to find required executable", exec_path)