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.
This commit is contained in:
Matthieu Gautier 2017-03-07 20:51:11 +01:00
parent ff97a67844
commit a49fb15964
2 changed files with 8 additions and 3 deletions

View File

@ -110,7 +110,7 @@ class ReleaseDownload(Source):
context.force_native_build = True context.force_native_build = True
for p in self.patches: for p in self.patches:
with open(pj(SCRIPT_DIR, 'patches', p), 'r') as patch_input: 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): def prepare(self):
self.command('download', self._download) self.command('download', self._download)

View File

@ -397,8 +397,13 @@ class BuildEnv:
kwargs = dict() kwargs = dict()
if input: if input:
kwargs['stdin'] = input kwargs['stdin'] = subprocess.PIPE
return subprocess.check_call(command, shell=True, cwd=cwd, env=env, stdout=log or sys.stdout, stderr=subprocess.STDOUT, **kwargs) 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: finally:
if log: if log:
log.close() log.close()