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

moved

  • Loading branch information...
lasote committed Mar 28, 2019
commit 29f07e4f391957eb308178735e694ee8507ee688
@@ -1,38 +1,16 @@
import io
import os
import subprocess
import sys
import tempfile
from contextlib import contextmanager
from subprocess import PIPE, Popen, STDOUT, CalledProcessError
from subprocess import PIPE, Popen, STDOUT

import six

from conans import load
from conans.client.tools import no_op
from conans.errors import ConanException
from conans.tools import chdir
from conans.unicode import get_cwd
from conans.util.files import decode_text


def check_output(cmd, folder=None, return_code=False):
_, tmp_file = tempfile.mkstemp()
with chdir(folder) if folder else no_op():
process = subprocess.Popen("{} > {}".format(cmd, tmp_file), shell=True)
process.communicate()

if return_code:
return process.returncode

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

output = load(tmp_file)
os.unlink(tmp_file)
return output


class ConanRunner(object):

def __init__(self, print_commands_to_output=False, generate_run_log_file=False,
@@ -3,8 +3,10 @@
import platform
import subprocess
import sys
import tempfile
from subprocess import CalledProcessError

from conans.client.tools import which
from conans.client.tools import which, no_op
from conans.client.tools.env import environment_append
from conans.errors import ConanException
from conans.model.version import Version
@@ -432,3 +434,22 @@ 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):
from conans.util.files import load
from conans.client.tools.files import chdir
_, tmp_file = tempfile.mkstemp()
with chdir(folder) if folder else no_op():
process = subprocess.Popen("{} > {}".format(cmd, tmp_file), shell=True)
process.communicate()

if return_code:
return process.returncode

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

output = load(tmp_file)
os.unlink(tmp_file)
return output
@@ -7,7 +7,7 @@

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

from conans.client.runner import check_output
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
@@ -129,8 +129,8 @@ def excluded_files(self):
ret = []
try:
file_paths = [os.path.normpath(
os.path.join(
os.path.relpath(folder, self.folder), el)).replace("\\", "/")
os.path.join(
os.path.relpath(folder, self.folder), el)).replace("\\", "/")
for folder, dirpaths, fs in walk(self.folder)
for el in fs + dirpaths]
if file_paths:
@@ -219,6 +219,7 @@ class SVN(SCMBase):
def __init__(self, folder=None, runner=None, *args, **kwargs):
def runner_no_strip(command):
return decode_text(subprocess.check_output(command, shell=True))

runner = runner or runner_no_strip
super(SVN, self).__init__(folder=folder, runner=runner, *args, **kwargs)

@@ -252,7 +253,8 @@ def run(self, command):
def _show_item(self, item, target='.'):
self.check_repo()
if self.version >= SVN.API_CHANGE_VERSION:
value = self.run("info --show-item {item} \"{target}\"".format(item=item, target=target))
value = self.run(
"info --show-item {item} \"{target}\"".format(item=item, target=target))
return value.strip()
else:
output = self.run("info --xml \"{target}\"".format(target=target))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.