Run a command.

    output
        return output if true

    directory
        directory to execute in

    runas
        user used to run buildout as

    env
        environment variables to set when running

    exitcode
        fails if cmd does not return this exit code
        (set to None to disable check)

    use_vt
        Use the new salt VT to stream output [experimental]

def _Popen(command,
           output=False,
           directory='.',
           runas=None,
           env=(),
           exitcode=0,
           use_vt=False,
           loglevel=None):
    '''
    Run a command.

    output
        return output if true

    directory
        directory to execute in

    runas
        user used to run buildout as

    env
        environment variables to set when running

    exitcode
        fails if cmd does not return this exit code
        (set to None to disable check)

    use_vt
        Use the new salt VT to stream output [experimental]

    '''
    ret = None
    directory = os.path.abspath(directory)
    if isinstance(command, list):
        command = ' '.join(command)
    LOG.debug('Running {0}'.format(command))  # pylint: disable=str-format-in-logging
    if not loglevel:
        loglevel = 'debug'
    ret = __salt__['cmd.run_all'](
        command, cwd=directory, output_loglevel=loglevel,
        runas=runas, env=env, use_vt=use_vt, python_shell=False)
    out = ret['stdout'] + '\n\n' + ret['stderr']
    if (exitcode is not None) and (ret['retcode'] != exitcode):
        raise _BuildoutError(out)
    ret['output'] = out
    if output:
        ret = out
    return ret