def _process(command, chdir=False):

    if chdir:
        log.debug('Changing directories to %s', chdir)
        cwd = os.getcwd()
        os.chdir(chdir)

    log.debug('Running %s', command)

    process = subprocess.Popen(
        command,
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=False)
    return_code = process.wait()

    if chdir:
        os.chdir(cwd)
    if return_code > 0:
        log.error('STDERR output: %s', process.stderr.read())

    return return_code
Helper method for running processes related to git.
dataset/ETHPy150Open markstory/lint-review/lintreview/git.py/_process