![]() ![]() ADAPTER_STATUS () if Netbios ( ncb ) = 0 : s. try : import netbios from win32wnet import Netbios ncb = netbios. ''' import os import socket import struct import sys try : import ctypes except ImportError : ctypes = None _version_ = '16.07.07' # '10.4.22' _all_ = ( 'getIPs', 'IP', 'isIP', 'getMACs', 'MAC', 'isMAC' ) if sys. This module does not support Python 2.3 and older and has not been tested on platforms other than the ones listed above. Tested on CentOS 4 (Intel), MacOS X 10.4.11 Tiger (Intel), MacOS X 10.3.9 Panther (PowerPC), RedHat 3 (Opteron), Solaris 10 (Opteron), Windows XP SP2 and SP3 and Windows Server 2003 R2 with 32-bit Python 2.4, 2.5, 2.6, 3.0 and/or 3.1, on CentOS 4 and 5 (Intel) with 64-bit Python 2.4 and 2.6, on MacOS X 10.11.5 with 64-bit Python 2.7.10 and 3.5.1 and on iOS 9.3.2 with 64-bit Pythonista 2.1 (on iPad). The core code is copied from standard Python 2.6 and 3.1 module Lib/uuid.py and then modified to: - use immutable classes IP and MAC like UUID, - handle any number of IP and MAC addresses, - collect IP and MAC addresses from several additional sources, - locate external programs only once, - use env and grep with ifconfig on *nixes, - support Python versions 2.4 thru 3.5, both 32- and 64-bit. Use python ipmac.py -debug to include debug output. For both, see module ipaddress (Python 3 only) at Run python ipmac.py to see examples and the test results. The IPv6 format is not supported, only IPv4. The return value is an IP respectively MAC instance if the given address is valid. Functions isIP and isMAC can be used to check an address. Both functions provide an optional argument to exclude specific IP or MAC instances. Functions getIPs and getMACs collect the available IP respectively MAC addresses from the underlying system. The IP class provides properties to check whether the address is link-local, loopback, multicast, a network address or network mask, private (non- routable), TEST-NET, THIS-HOST or THIS-NET. Instances of IP and MAC classes are immutable. Class IP and MAC represent an IP respectively a MAC address. # coding: utf-8 '''This module provides 2 classes and 4 functions to, obtain, check and convert IP and MAC addresses. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |