示例#1
0
def get_options():
    options, args = parser.parse_args()
    if args:
        parser.error("does not take positional arguments: %r" % (args,))

    options.mode = options.mode.lower()

    if options.regtype.lower() == "udp":
        if options.reghost is None:
            options.reghost = "255.255.255.255"
        options.registrar = UDPRegistryClient(ip=options.reghost, port=options.regport)
    elif options.regtype.lower() == "tcp":
        if options.reghost is None:
            parser.error("must specific --registry-host")
        options.registrar = TCPRegistryClient(ip=options.reghost, port=options.regport)
    else:
        parse.error("invalid registry type %r" % (options.regtype,))

    if options.vdbfile:
        if not os.path.exists(options.vdbfile):
            parser.error("vdb file does not exist")
        options.authenticator = VdbAuthenticator.from_file(options.vdbfile, mode="r")
    else:
        options.authenticator = None

    options.handler = "serve_%s" % (options.mode,)
    if options.handler not in globals():
        parser.error("invalid mode %r" % (options.mode,))

    return options
示例#2
0
def get_options():
    options, args = parser.parse_args()
    if args:
        parser.error("does not take positional arguments: %r" % (args, ))

    options.mode = options.mode.lower()

    if options.regtype.lower() == "udp":
        if options.reghost is None:
            options.reghost = "255.255.255.255"
        options.registrar = UDPRegistryClient(ip=options.reghost,
                                              port=options.regport)
    elif options.regtype.lower() == "tcp":
        if options.reghost is None:
            parser.error("must specific --registry-host")
        options.registrar = TCPRegistryClient(ip=options.reghost,
                                              port=options.regport)
    else:
        parse.error("invalid registry type %r" % (options.regtype, ))

    if options.vdbfile:
        if not os.path.exists(options.vdbfile):
            parser.error("vdb file does not exist")
        options.authenticator = VdbAuthenticator.from_file(options.vdbfile,
                                                           mode="r")
    else:
        options.authenticator = None

    options.handler = "serve_%s" % (options.mode, )
    if options.handler not in globals():
        parser.error("invalid mode %r" % (options.mode, ))

    return options
def getOptions():
    """Parses options for our various servers."""
    options, args = PARSER.parse_args()
    if args:
        PARSER.error("does not take positional arguments: %r" % (args, ))

    options.mode = options.mode.lower()

    if options.regtype.lower() == "udp":
        if options.reghost is None:
            options.reghost = "255.255.255.255"
        options.registrar = UDPRegistryClient(ip=options.reghost,
                                              port=options.regport)
    elif options.regtype.lower() == "tcp":
        if options.reghost is None:
            PARSER.error("must specific --registry-host")
        options.registrar = TCPRegistryClient(ip=options.reghost,
                                              port=options.regport)
    else:
        PARSER.error("invalid registry type %r" % (options.regtype, ))

    if options.vdbfile:
        if not os.path.exists(options.vdbfile):
            PARSER.error("vdb file does not exist")
        options.authenticator = VdbAuthenticator.from_file(options.vdbfile,
                                                           mode="r")
    else:
        options.authenticator = None

    mode = options.mode
    options.handler = "serve%s" % (mode[0].upper() + mode[1:], )
    if options.handler not in globals():
        PARSER.error("invalid mode %r" % (options.mode, ))

    return options
示例#4
0
def getOptions():
    """Parses options for our various servers."""
    options, args = PARSER.parse_args()
    if args:
        PARSER.error("does not take positional arguments: %r" % (args,))

    options.mode = options.mode.lower()

    if options.regtype.lower() == "udp":
        if options.reghost is None:
            options.reghost = "255.255.255.255"
        options.registrar = UDPRegistryClient(ip = options.reghost, port = options.regport)
    elif options.regtype.lower() == "tcp":
        if options.reghost is None:
            PARSER.error("must specific --registry-host")
        options.registrar = TCPRegistryClient(ip = options.reghost, port = options.regport)
    else:
        PARSER.error("invalid registry type %r" % (options.regtype,))

    if options.vdbfile:
        if not os.path.exists(options.vdbfile):
            PARSER.error("vdb file does not exist")
        options.authenticator = VdbAuthenticator.from_file(options.vdbfile, mode = "r")
    else:
        options.authenticator = None

    mode = options.mode
    options.handler = "serve%s" % (mode[0].upper() + mode[1:],)
    if options.handler not in globals():
        PARSER.error("invalid mode %r" % (options.mode,))

    return options
示例#5
0
def main():
    options = get_options()
    vdb = VdbAuthenticator.from_file(options.filename)
    
    if options.listonly:
        list_users(vdb, options)
    elif options.delete:
        del_user(vdb, options)
        print "OK"
    elif options.add:
        set_user(vdb, options)
        print "OK"
    else:
        parser.error("No action specified")
示例#6
0
def main():
    options = get_options()
    vdb = VdbAuthenticator.from_file(options.filename)
    
    if options.listonly:
        list_users(vdb, options)
    elif options.delete:
        del_user(vdb, options)
        print( "OK" )
    elif options.add:
        set_user(vdb, options)
        print( "OK" )
    else:
        parser.error("No action specified")