tools/utils.py
def run_cmd(command, work_dir=None, chroot=None, redirect=False):
    """Run a command in the forground

    Positional arguments:
    command - the command to run

    Keyword arguments:
    work_dir - the working directory to run the command in
    chroot - the chroot to run the command in
    redirect - redirect the stderr to a pipe to be used later
    """
    if chroot:
        # Conventions managed by the web team for the mbed.org build system
        chroot_cmd = [
            '/usr/sbin/chroot', '--userspec=33:33', chroot
        ]
        for element in command:
            chroot_cmd += [element.replace(chroot, '')]

        logging.debug("Running command %s", ' '.join(chroot_cmd))
        command = chroot_cmd
        work_dir = None

    try:
        process = Popen(command, stdout=PIPE,
                        stderr=STDOUT if redirect else PIPE, cwd=work_dir)
        _stdout, _stderr = process.communicate()
    except OSError:
        print "[OS ERROR] Command: "+(' '.join(command))
        raise

    return _stdout, _stderr, process.returncode
Run a command in the forground

    Positional arguments:
    command - the command to run

    Keyword arguments:
    work_dir - the working directory to run the command in
    chroot - the chroot to run the command in
    redirect - redirect the stderr to a pipe to be used later
    
Run a command in the forground
Positional arguments:
command - the command to run

Keyword arguments:
work_dir - the working directory to run the command in
chroot - the chroot to run the command in
redirect - redirect the stderr to a pipe to be used later
Run a command in the forground Positional arguments : command - the command to run Keyword arguments : work_dir - the working directory to run the command in chroot - the chroot to run the command in redirect - redirect the stderr to a pipe to be used later
def run_cmd(command, work_dir=None, chroot=None, redirect=False):
    if chroot:
        chroot_cmd = [
            '/usr/sbin/chroot', '--userspec=33:33', chroot
        ]
        for element in command:
            chroot_cmd += [element.replace(chroot, '')]
        logging.debug("Running command %s", ' '.join(chroot_cmd))
        command = chroot_cmd
        work_dir = None
    try:
        process = Popen(command, stdout=PIPE,
                        stderr=STDOUT if redirect else PIPE, cwd=work_dir)
        _stdout, _stderr = process.communicate()
    except OSError:
        print "[OS ERROR] Command: "+(' '.join(command))
        raise
    return _stdout, _stderr, process.returncode
def run_cmd ( command , work_dir = None , chroot = None , redirect = False ) : if chroot : chroot_cmd = [ '/usr/sbin/chroot' , '--userspec=33:33' , chroot ] for element in command : chroot_cmd += [ element . replace ( chroot , '' ) ] logging . debug ( "Running command %s" , ' ' . join ( chroot_cmd ) ) command = chroot_cmd work_dir = None try : process = Popen ( command , stdout = PIPE , stderr = STDOUT if redirect else PIPE , cwd = work_dir ) _stdout , _stderr = process . communicate ( ) except OSError : print "[OS ERROR] Command: " + ( ' ' . join ( command ) ) raise return _stdout , _stderr , process . returncode
Run a command in the forground
Positional arguments:
command - the command to run
Run a command in the forground Positional arguments : command - the command to run
"""Run a command in the forground

    Positional arguments:
    command - the command to run

    Keyword arguments:
    work_dir - the working directory to run the command in
    chroot - the chroot to run the command in
    redirect - redirect the stderr to a pipe to be used later
    """ # Conventions managed by the web team for the mbed.org build system
command
work_dir
chroot
redirect