コード例 #1
0
def assign_constraints():
    ''' Assign default values and input to constraints '''
    kwargs = parse_input()
    frq = kwargs.pop("frequency")
    kwargs["mip"] = assign_mips(frq=frq,mip=kwargs["mip"])
    newkwargs=kwargs
    for k,v in list(kwargs.items()):
        if v is None or v==[]: newkwargs.pop(k)
    return newkwargs
コード例 #2
0
ファイル: add_warning.py プロジェクト: coecms/ARCCSSive
def assign_constraints():
    """ Assign default values and input to constraints """
    kwargs = parse_input()
    admin = kwargs.pop("admin")
    warning = kwargs.pop("warning")[0]
    if len(warning) <= 10:
        print("Warning '", warning, "' is too short")
        sys.exit()
    email = kwargs.pop("email")[0]
    if "@" not in email:
        print(email, " is not a valid e-mail")
        sys.exit()
    # check if this is an authorised user
    if admin:
        if os.environ["USER"] not in ["pxp581", "tae599"]:
            print(os.environ["USER"] + " is not an authorised admin")
            sys.exit()
    frq = kwargs.pop("frequency")
    kwargs["mip"] = assign_mips(frq=frq, mip=kwargs["mip"])
    newkwargs = kwargs
    for k, v in list(kwargs.items()):
        if v is None or v == []:
            newkwargs.pop(k)
    return newkwargs, admin, warning, email