def RunCommand(cmd):
    p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, \
                  stderr=STDOUT, close_fds=True)
    ex = p.wait()
    if ex != 0:
        stdout, stderr = "", ""
        if p.stdout is not None: stdout = p.stdout.read()
        if p.stderr is not None: stderr = p.stderr.read()
        message("ERROR: command '%s' failed.\n\nSTDOUT:%s\nSTDERR:%s"%(cmd, stdout, stderr))
    return ex
dataset/ETHPy150Open mgymrek/pybamview/pybamview/utils.py/RunCommand/original