示例#1
0
文件: getmac.py 项目: Frizz925/getmac
def _uuid_ip(ip):
    from uuid import _arp_getnode
    backup = socket.gethostbyname
    try:
        socket.gethostbyname = lambda x: ip
        mac1 = _arp_getnode()
        if mac1 is not None:
            mac1 = _uuid_convert(mac1)
            mac2 = _arp_getnode()
            mac2 = _uuid_convert(mac2)
            if mac1 == mac2:
                return mac1
    except Exception:
        raise
    finally:
        socket.gethostbyname = backup
        def _uuid_ip():
            from uuid import _arp_getnode

            _gethostbyname = socket.gethostbyname
            try:
                socket.gethostbyname = lambda x: ip
                mac1 = _arp_getnode()
                if mac1 is not None:
                    mac1 = ':'.join(
                        ('%012X' % mac1)[i:i + 2] for i in range(0, 12, 2))
                    mac2 = _arp_getnode()
                    mac2 = ':'.join(
                        ('%012X' % mac2)[i:i + 2] for i in range(0, 12, 2))
                    if mac1 == mac2:
                        return mac1
            finally:
                socket.gethostbyname = _gethostbyname
        def _uuid_ip():
            # noinspection PyUnresolvedReferences,PyProtectedMember
            from uuid import _arp_getnode

            _gethostbyname = socket.gethostbyname
            try:
                socket.gethostbyname = lambda x: ip
                mac1 = _arp_getnode()
                if mac1 is not None:
                    mac1 = ':'.join(
                        ('%012X' % mac1)[i:i + 2] for i in range(0, 12, 2))
                    mac2 = _arp_getnode()
                    mac2 = ':'.join(
                        ('%012X' % mac2)[i:i + 2] for i in range(0, 12, 2))
                    if mac1 == mac2:
                        return mac1
            finally:
                socket.gethostbyname = _gethostbyname
示例#4
0
 def test_arp_getnode(self):
     node = uuid._arp_getnode()
     self.check_node(node, 'arp', True)
示例#5
0
 def test_arp_getnode(self):
     node = uuid._arp_getnode()
     if node is not None:
         self.check_node(node, 'arp')
示例#6
0
 def test_arp_getnode(self):
     node = uuid._arp_getnode()
     if node is not None:
         self.check_node(node, 'arp')
示例#7
0
文件: nodes.py 项目: xxoolm/Ryven
 def update_event(self, inp=-1):
     self.set_output_val(0, uuid._arp_getnode())
示例#8
0
 def test_arp_getnode(self):
     return
     node = uuid._arp_getnode()
     self.check_node(node, 'arp')