demotool.py 文件源码

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

项目:loopchain 作者: theloopkr 项目源码 文件源码
def menu4_1(params=None):
    admin_manager = AdminManager("demotool")

    print("\nInput Peer Target [IP]:[port] (default '' -> 127.0.0.1:7100, [port] -> 127.0.0.1:[port])")
    choice = input(" >>  ")
    if choice == "":
        choice = "127.0.0.1:7100"
    elif choice.find(':') == -1:
        choice = "127.0.0.1:" + choice

    select_channel_index = 0
    select_channel_string = ""
    for channel in admin_manager.get_channel_list():
        if select_channel_index != 0:
            select_channel_string += ", "
        select_channel_string += f"{select_channel_index}: {admin_manager.get_channel_list()[select_channel_index]}"
        select_channel_index += 1

    print(f"Select Channel ({select_channel_string})")
    channel_choice = input(" >>  ")
    try:
        test_globals["channel_name"] = admin_manager.get_channel_list()[int(channel_choice)]
    except Exception as e:
        print(f"wrong channel number! Now use default channel({admin_manager.get_channel_list()[0]})\n")
        test_globals["channel_name"] = admin_manager.get_channel_list()[0]

    print("your input: " + choice)
    channel = grpc.insecure_channel(choice)
    peer_stub = loopchain_pb2_grpc.PeerServiceStub(channel)
    response = peer_stub.GetStatus(loopchain_pb2.StatusRequest(request="hello"), conf.GRPC_TIMEOUT)
    print("Peer Status: " + str(response))
    menu4(peer_stub)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号