genvid.toolbox.NetworkTool
- class genvid.toolbox.NetworkTool(**kwargs)
Bases:
BaseTool
Platform abstraction of network utilities.
- NAME = 'network'
The name of the logger for this tool. Must be redefined in children.
- AF_INET = 2
IPv4 Family
- AF_INET6 = 23
IPv6 Family
- AF_LINK = -1
MAC Address Family
- static get_network_interfaces()
Return the list of network interfaces on the system.
- static get_network_addresses(interface, family)
Return the list of addresses for this interface.
Args:
interface: The name of the interface.
family: The family type of the addresses.
- get_ip()
Return the local IP address.
- CHECKIP_URL = 'https://checkip.amazonaws.com'
URL to use for checking the IP address with
get_external_ip()
. For future compatiblity, the URL should return a bare string containing the external visible IP of the caller’s host.New in version 1.15.0.
- get_external_ip()
Return the external IP of the current machine.
It uses
CHECKIP_URL
for the default server.Changed in version 1.15.0: Use the
CHECKIP_URL
to fetch the IP.Changed in version 1.19.0: Remove the support for ipgetter package and make it a normal method. Also, use
GENVID_CHECKIP_URL
instead, for more flexibility.
- GENVID_DEFAULT_IP
A mirror of
GENVID_DEFAULT_IP
. It specifies the IP address to use for the local services. Defaults to 127.0.0.1.
- GENVID_CHECKIP_URL
A mirror of
GENVID_CHECKIP_URL
. It specifies the url to fetch to retrieve the external IP address of the machine. The default is specified through theCHECKIP_URL
.New in version 1.19.0.
- get_interface_from_ip(ip, family=AddressFamily.AF_INET)
Try to find the the IPInterface containing the specified IP address.
- get_network_interface(ip, family=AddressFamily.AF_INET)
Return the network interface associated with an IP address.
Args:
ip: The IP address to match.
family: The family of the IP address. Defaults to AF_INET (IPv4).
- get_nameservers_linux()
Return the list of nameservers configured in /etc/resolv.conf.
- get_nameservers_windows()
Return the list of nameservers configured on a Windows system.
- get_nameservers()
Return the list of nameservers on the system.
- urlretrieve_report(url, size, total)
Default
urlretrieve()
log function.
- class network.NetworkTool
Implementation of
genvid.toolbox.NetworkTool