package_linter.py 文件源码

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

项目:package_linter 作者: YunoHost 项目源码 文件源码
def check_verifications_done_before_modifying_system(script):
    """
    Check if verifications are done before modifying the system
    """
    ok = True
    modify_cmd = ''
    cmds = ("cp", "mkdir", "rm", "chown", "chmod", "apt-get", "apt", "service",
           "find", "sed", "mysql", "swapon", "mount", "dd", "mkswap", "useradd")
    cmds_before_exit = []
    is_exit = False
    for cmd in script:
        if "ynh_die" == cmd or "exit " == cmd:
            is_exit = True
            break
        cmds_before_exit.append(cmd)

    if not is_exit:
        return

    for cmd in cmds_before_exit:
        if "ynh_die" == cmd or "exit " == cmd:
            break
        if not ok or cmd in cmds:
            modify_cmd = cmd
            ok = False
            break

    if not ok:
        print_wrong("[YEP-2.4] 'ynh_die' or 'exit' command is executed with system modification before (cmd '%s').\n"
        "This system modification is an issue if a verification exit the script.\n"
        "You should move this verification before any system modification." % (modify_cmd) , False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号