예제 #1
0
def main(argv):
    global mb, quiet, node_to_connect_to

    try:
        opts, args = getopt.getopt(argv[1:], "?dn:c:qr:")
    except getopt.error as info:
        print(info)
        sys.exit(1)

    hostName = "localhost"
    ownNodeName = "py_interface_test"
    cookie = "cookie"
    doDebug = 0

    for (optchar, optarg) in opts:
        if optchar == "-?":
            print("Usage: %s erlnode" % argv[0])
            sys.exit(1)
        elif optchar == "-c":
            cookie = optarg
        elif optchar == "-d":
            doDebug = 1
        elif optchar == "-q":
            quiet = 1
        elif optchar == "-n":
            ownNodeName = optarg
        elif optchar == "-r":
            global res_pidname
            res_pidname = optarg

    if len(args) >= 4:
        node_to_connect_to = args[0]
        mod = args[1]
        fn = args[2]
        args = eval(args[3])
    else:
        print("Error: missing args: " + "node_to_connect_to mod fn args")
        sys.exit(1)

    if doDebug:
        erl_common.DebugOnAll()

    print("Creating node...")
    n = erl_node.ErlNode(ownNodeName, erl_opts.ErlNodeOpts(cookie=cookie))
    n.SetEpmdConnectedOkCb(
        erl_common.Callback(__EpmdConnectedOk, node_to_connect_to, mod, fn,
                            args, __RpcResult))
    print("Publishing node...")
    n.Publish()
    print("Creating mbox...")
    mb = n.CreateMBox(None)
    m = n.CreateMBox(__TestMBoxCallback)

    evhand = erl_eventhandler.GetEventHandler()
    evhand.PushReadEvent(sys.stdin, __FlushStdout)

    print("-GOING LOOPING-")  # Erlang side will pick this text up
    sys.stdout.flush()

    evhand.Loop()
예제 #2
0
def main(argv):
    global mb, quiet

    try:
        opts, args = getopt.getopt(argv[1:], "?dn:c:q")
    except getopt.error as info:
        print(info)
        sys.exit(1)

    hostName = "localhost"
    ownNodeName = "py_interface_test"
    cookie = "cookie"
    doDebug = 0

    for (optchar, optarg) in opts:
        if optchar == "-?":
            print("Usage: %s erlnode" % argv[0])
            sys.exit(1)
        elif optchar == "-c":
            cookie = optarg
        elif optchar == "-d":
            doDebug = 1
        elif optchar == "-q":
            quiet = 1
        elif optchar == "-n":
            ownNodeName = optarg

    if doDebug:
        erl_common.DebugOnAll()

    print("Creating node...")
    n = erl_node.ErlNode(ownNodeName, erl_opts.ErlNodeOpts(cookie=cookie))
    print("Publishing node...")
    n.Publish()
    print("Creating mbox...")
    mb = n.CreateMBox(None)
    m = n.CreateMBox(__TestMBoxCallback)
    print("Registering mbox as p...")
    m.RegisterName("p")

    evhand = erl_eventhandler.GetEventHandler()
    evhand.PushReadEvent(sys.stdin, __FlushStdout)

    print("-GOING LOOPING-")  # Erlang side will pick this text up
    sys.stdout.flush()
    evhand.Loop()
예제 #3
0
def start_looping(own_node_name, cookie, debug_on_all):
    if debug_on_all:
        erl_common.DebugOnAll()

    LOGGER.debug("Creating node...")
    node = erl_node.ErlNode(own_node_name, erl_opts.ErlNodeOpts(cookie=cookie))
    LOGGER.debug("Publishing node...")
    node.Publish()
    LOGGER.debug("Creating mbox...")
    mbox = node.CreateMBox(__TestMBoxCallback)
    LOGGER.debug("Registering mbox as p...")
    mbox.RegisterName("p")

    event_handler = erl_eventhandler.GetEventHandler()

    event_thread = Thread(target=event_handler.Loop, args=())
    # not necessary to flag as daemon since thread will end when stopping loop
    event_thread.daemon = True
    event_thread.start()
   
    return node, mbox, event_handler
예제 #4
0
    cookie = "cookie"
    doDebug = 0

    for (optchar, optarg) in opts:
        if optchar == "-?":
            print "Usage: %s erlnode" % argv[0]
            sys.exit(1)
        elif optchar == "-c":
            cookie = optarg
        elif optchar == "-d":
            doDebug = 1
        elif optchar == "-n":
            ownNodeName = optarg

    if doDebug:
        erl_common.DebugOnAll()

    print "Creating node..."
    n = erl_node.ErlNode(ownNodeName, erl_opts.ErlNodeOpts(cookie=cookie))
    print "Publishing node..."
    n.Publish()
    print "Creating mbox..."
    mb = n.CreateMBox(None)
    m = n.CreateMBox(__TestMBoxCallback)
    print "Registering mbox as p..."
    m.RegisterName("p")

    print "Looping..."
    evhand = erl_eventhandler.GetEventHandler()
    evhand.Loop()