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

replace check output

  • Loading branch information...
lasote committed Mar 28, 2019
commit 47fe7054ea9ff2ed14ce3d565a01167f04b224a1
@@ -6,8 +6,8 @@
import tempfile
from subprocess import CalledProcessError, PIPE

from conans.client.tools.env import environment_append, no_op
from conans.client.tools.files import chdir, load, 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
@@ -437,20 +437,18 @@ def get_gnu_triplet(os_, arch, compiler=None):


def check_output(cmd, folder=None, return_code=False):
fd, tmp_file = tempfile.mkstemp()
with chdir(folder) if folder else no_op():
try:
process = subprocess.Popen("{} > {}".format(cmd, tmp_file), shell=True, stderr=PIPE)
process.communicate()
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 return_code:
return process.returncode

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

output = load(tmp_file)
return output
finally:
os.close(fd)
os.unlink(tmp_file)
output = load(tmp_file)
return output
finally:
os.unlink(tmp_file)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.