From a49fb159649c67826d4bfe0889df459ad1ceb94c Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 7 Mar 2017 20:51:11 +0100 Subject: [PATCH] BuildEnv.run_command now take a str as input instead of a file object. We can get a str from a file object. The contrary is more difficult. --- dependency_utils.py | 2 +- kiwix-build.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dependency_utils.py b/dependency_utils.py index 8182553..6959ac1 100644 --- a/dependency_utils.py +++ b/dependency_utils.py @@ -110,7 +110,7 @@ class ReleaseDownload(Source): context.force_native_build = True for p in self.patches: with open(pj(SCRIPT_DIR, 'patches', p), 'r') as patch_input: - self.buildEnv.run_command("patch -p1", self.extract_path, context, input=patch_input) + self.buildEnv.run_command("patch -p1", self.extract_path, context, input=patch_input.read()) def prepare(self): self.command('download', self._download) diff --git a/kiwix-build.py b/kiwix-build.py index 49aeaa8..f9b6a38 100755 --- a/kiwix-build.py +++ b/kiwix-build.py @@ -397,8 +397,13 @@ class BuildEnv: kwargs = dict() if input: - kwargs['stdin'] = input - return subprocess.check_call(command, shell=True, cwd=cwd, env=env, stdout=log or sys.stdout, stderr=subprocess.STDOUT, **kwargs) + kwargs['stdin'] = subprocess.PIPE + process = subprocess.Popen(command, shell=True, cwd=cwd, env=env, stdout=log or sys.stdout, stderr=subprocess.STDOUT, **kwargs) + if input: + process.communicate(input.encode()) + retcode = process.wait() + if retcode: + raise subprocess.CalledProcessError(retcode, command) finally: if log: log.close()