From 6affb64150d052881ee3a8725181267a96b3711c Mon Sep 17 00:00:00 2001 From: Mathieu Comandon Date: Sun, 9 Feb 2014 12:25:39 +0100 Subject: [PATCH] Add 'format' option to extract installer task --- lutris/installer.py | 5 ++++- lutris/util/extract.py | 13 +++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lutris/installer.py b/lutris/installer.py index 47928f16f..cb5a87b11 100644 --- a/lutris/installer.py +++ b/lutris/installer.py @@ -449,6 +449,8 @@ class ScriptInterpreter(object): exec_id = data args = [] exec_path = self._get_file(exec_id) + if not exec_path: + raise ScriptingError("Unable to find file %s" % exec_id, exec_id) if not os.path.exists(exec_path): raise ScriptingError("Unable to find required executable", exec_path) @@ -535,8 +537,9 @@ class ScriptInterpreter(object): logger.debug(msg) self.parent.set_status(msg) merge_single = not 'nomerge' in data + extractor = data.get('format') logger.debug("extracting file %s to %s", filename, dest_path) - extract.extract_archive(filename, dest_path, merge_single) + extract.extract_archive(filename, dest_path, merge_single, extractor) def _append_steam_data_to_files(self, runner_class): steam_runner = runner_class() diff --git a/lutris/util/extract.py b/lutris/util/extract.py index 5ccfdb6a1..16a9d1cbe 100644 --- a/lutris/util/extract.py +++ b/lutris/util/extract.py @@ -8,18 +8,19 @@ from lutris.util.system import merge_folders from lutris.util.log import logger -def extract_archive(path, to_directory='.', merge_single=True): +def extract_archive(path, to_directory='.', merge_single=True, extractor=None): path = os.path.abspath(path) logger.debug("Extracting %s to %s", path, to_directory) - if path.endswith('.zip'): + if path.endswith('.zip') or extractor == 'zip': opener, mode = zipfile.ZipFile, 'r' - elif path.endswith('.tar.gz') or path.endswith('.tgz'): + elif path.endswith('.tar.gz') or path.endswith('.tgz') \ + or extractor == 'tgz': opener, mode = tarfile.open, 'r:gz' - elif path.endswith('.gz'): + elif path.endswith('.gz') or extractor == 'gzip': decompress_gz(path, to_directory) return - - elif path.endswith('.tar.bz2') or path.endswith('.tbz'): + elif path.endswith('.tar.bz2') or path.endswith('.tbz') \ + or extractor == 'bz2': opener, mode = tarfile.open, 'r:bz2' else: raise RuntimeError(