travis.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:doctr 作者: drdoctr 项目源码 文件源码
def run(args, shell=False, exit=True):
    """
    Run the command ``args``.

    Automatically hides the secret GitHub token from the output.

    If shell=False (recommended for most commands), args should be a list of
    strings. If shell=True, args should be a string of the command to run.

    If exit=True, it exits on nonzero returncode. Otherwise it returns the
    returncode.
    """
    if "GH_TOKEN" in os.environ:
        token = get_token()
    else:
        token = b''

    if not shell:
        command = ' '.join(map(shlex.quote, args))
    else:
        command = args
    command = command.replace(token.decode('utf-8'), '~'*len(token))
    print(blue(command))
    sys.stdout.flush()

    returncode = run_command_hiding_token(args, token, shell=shell)

    if exit and returncode != 0:
        sys.exit(red("%s failed: %s" % (command, returncode)))
    return returncode
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号