Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/replace check output #4854

Merged
merged 14 commits into from Mar 28, 2019
@@ -3,9 +3,11 @@
import platform
import subprocess
import sys
import tempfile
from subprocess import CalledProcessError, PIPE

from conans.client.tools import which
from conans.client.tools.env import environment_append
from conans.client.tools.files import load, which
from conans.errors import ConanException
from conans.model.version import Version
from conans.util.fallbacks import default_output
@@ -432,3 +434,24 @@ def get_gnu_triplet(os_, arch, compiler=None):
op_system += "_ilp32" # https://wiki.linaro.org/Platform/arm64-ilp32

return "%s-%s" % (machine, op_system)


def check_output(cmd, folder=None, return_code=False):
tmp_file = tempfile.mktemp()
try:
process = subprocess.Popen("{} > {}".format(cmd, tmp_file), shell=True, stderr=PIPE, cwd=folder)
process.communicate()

if return_code:
return process.returncode

if process.returncode:
raise CalledProcessError(process.returncode, cmd)

output = load(tmp_file)
return output
finally:
try:
os.unlink(tmp_file)
except:
pass
@@ -1,4 +1,3 @@

import os
import platform
import re
@@ -8,6 +7,7 @@

from six.moves.urllib.parse import quote_plus, unquote, urlparse

from conans.client.tools import check_output
from conans.client.tools.env import environment_append, no_op
from conans.client.tools.files import chdir
from conans.errors import ConanException
@@ -53,7 +53,7 @@ def run(self, command):
with chdir(self.folder) if self.folder else no_op():
with environment_append({"LC_ALL": "en_US.UTF-8"}) if self._force_eng else no_op():
if not self._runner:
return decode_text(subprocess.check_output(command, shell=True, stderr=STDOUT).strip())
return check_output(command).strip()
else:
return self._runner(command)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.