Exemplo n.º 1
0
def invoke(cmd):
    """ log a command, run it, fail if it fails """
    log = get_logger("SHELL")
    log(cmd)
    rc = os.system(cmd)
    if not rc == 0:
        log("command failed, rc: %s" % rc)
        raise Exception("boom")
Exemplo n.º 2
0
def invoke(cmd):
    """ log a command, run it, fail if it fails """
    log = get_logger('SHELL')
    log(cmd)
    rc = os.system(cmd)
    if not rc == 0:
        log("command failed, rc: %s" % rc)
        raise Exception("boom")
Exemplo n.º 3
0
def invoke(cmd, check_rc=True, check_output=False):
    """ log a command, run it, and (usually) fail if it fails """
    log = get_logger("SHELL")
    log(cmd)

    if check_output:
        try:
            return subprocess.check_output(cmd, shell=True)
        except subprocess.CalledProcessError:
            return ""

    else:
        rc = os.system(cmd)
        if check_rc and not rc == 0:
            msg = "command failed, rc: %s" % rc
            log(msg)
            raise Exception(msg)
        return rc
Exemplo n.º 4
0
def invoke(cmd, check_rc=True, check_output=False):
    """ log a command, run it, and (usually) fail if it fails """
    log = get_logger('SHELL')
    log(cmd)

    if check_output:
        try:
            return subprocess.check_output(cmd, shell=True)
        except subprocess.CalledProcessError:
            return ""

    else:
        rc = os.system(cmd)
        if check_rc and not rc == 0:
            msg = "command failed, rc: %s" % rc
            log(msg)
            raise Exception(msg)
        return rc