from logging import getLogger
from os import system

def shell(cmd, quiet=False, allow_failure = False):
    """runs a shell command, echoing output and raising
    a SystemExit if the command fails"""
    logger = getLogger("metamake.shell")
    if not quiet:
        logger.info(cmd)
    retcode = system(cmd)
    if retcode is not 0 and not allow_failure:
        raise SystemExit(retcode)