Ejemplo n.º 1
0
def init_myIP():
    monitoring.log("log.Set the peer's own IP address.")
    os = platform.system()
    if os == 'Linux':
        monitoring.log("log.Peer's os is Linux.")
        # For raspberry pi, we use wlan,
        # so we need to figure out the IP address in a different way.
        nodeproperty.My_IP_address = file_controller.get_my_ip_rpi()
    elif os == 'Windows':
        monitoring.log("log.Peer's os is Windows.")
        nodeproperty.My_IP_address = file_controller.get_my_ip()

        monitoring.log("log.Peer's IP: " + nodeproperty.My_IP_address)
Ejemplo n.º 2
0
    # 요기부분이.
    nodeproperty.my_node.print_table()


def set_node():
    # nodeproperty.my_ip_address = socket.gethostbyname(
    #     socket.gethostname())
    # nodeinfo.txt 에 내용이 없다면 최초 참여(initialize), 있다면 동기화(synchronize)
    initialize()


''' nodeinfo.txt 파일을 노드마다 다르게 작성한 후에 테스트 필요
    try:
        f = open('nodeinfo.txt', 'r')
        tmp = f.read()
        f.close()
        if tmp == '':
            initialize()
        else:
            synchronize()

    except IOError as e:
        print("file open error - nodeinfo.txt", e)
        initialize()
'''

if __name__ == '__main__':
    nodeproperty.My_IP_address = file_controller.get_my_ip_rpi()
    set_node()
    # Property.my_node.write_table()