from umit.icm.agent.rpc.MessageFactory import MessageFactory

address = raw_input("Input peer address(ip:port): ")
ip, port = address.split(':')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
s.connect((ip, int(port)))
newFlag = 'y'

labels = ('', 'optional', 'required', 'repeated')
cpp_types = ('', 'int32', 'int64', 'uint32', 'uint64', 'double', 'float',
         'bool', 'enum', 'string', 'message')

while newFlag == 'y':
    print("---------Client Request Begin---------")
    msg_type = raw_input("Message type: ")
    request_msg = MessageFactory.create(msg_type)
    for field in request_msg.DESCRIPTOR.fields:
        value = raw_input("[%s] %s(%s): " % (labels[field.label], field.name,
                                             cpp_types[field.cpp_type]))
        if field.label == field.LABEL_REQUIRED:
            while value == '':
                print("Error! This field is required.")
                value = raw_input("[%s] %s(%s): " % (labels[field.label],
                                                    field.name,
                                                    cpp_types[field.cpp_type]))
        if field.cpp_type < 5:
            request_msg._fields[field] = int(value)
        elif field.cpp_type < 7:
            request_msg._fields[field] = float(value)
        elif field.cpp_type == 7:
            request_msg._fields[field] = bool(value)
from umit.icm.agent.rpc.MessageFactory import MessageFactory

address = raw_input("Input peer address(ip:port): ")
ip, port = address.split(':')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
s.connect((ip, int(port)))
newFlag = 'y'

labels = ('', 'optional', 'required', 'repeated')
cpp_types = ('', 'int32', 'int64', 'uint32', 'uint64', 'double', 'float',
             'bool', 'enum', 'string', 'message')

while newFlag == 'y':
    print("---------Client Request Begin---------")
    msg_type = raw_input("Message type: ")
    request_msg = MessageFactory.create(msg_type)
    for field in request_msg.DESCRIPTOR.fields:
        value = raw_input(
            "[%s] %s(%s): " %
            (labels[field.label], field.name, cpp_types[field.cpp_type]))
        if field.label == field.LABEL_REQUIRED:
            while value == '':
                print("Error! This field is required.")
                value = raw_input("[%s] %s(%s): " %
                                  (labels[field.label], field.name,
                                   cpp_types[field.cpp_type]))
        if field.cpp_type < 5:
            request_msg._fields[field] = int(value)
        elif field.cpp_type < 7:
            request_msg._fields[field] = float(value)
        elif field.cpp_type == 7: