genvid.toolbox.NetworkTool¶
-
class
genvid.toolbox.
NetworkTool
(**kwargs)¶ Bases:
genvid.toolbox.basetool.BaseTool
Platform abstraction of Network utilities
-
AF_INET
= 2¶ IPv4 Family
-
AF_INET6
= 23¶ IPv6 Family
-
AF_LINK
= -1¶ MAC Address Family
-
GENVID_DEFAULT_IP
= None¶ A mirror of
GENVID_DEFAULT_IP
. It specify the IP address to use for the local services. Default to 127.0.0.1.
-
NAME
= 'network'¶
-
static
get_external_ip
()¶ Return the external IP of the current machine.
-
get_interface_from_ip
(ip, family=<AddressFamily.AF_INET: 2>)¶ Given an ip address, try to find the the IPInterface containing this IP.
-
get_ip
()¶ Return the local IP address.
-
get_nameservers
()¶ Return the list of nameservers on the system.
-
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.
-
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_network_interface
(ip, family=<AddressFamily.AF_INET: 2>)¶ Return the network interface associated with an IP address.
- Args:
ip: The IP address to match.
family: The family of the IP address (default to AF_INET (IPv4))
-
static
get_network_interfaces
()¶ Return the list of network interfaces on the system
-
urlretrieve
(url: str, filename: typing.Union[pathlib.Path, str, NoneType] = None) → pathlib.Path¶ Download an url.
Progress will be shown using
urlretrieve_report()
.Parameters: - url – The url to retrieve.
- filename – The destination file. If None, a temporary file will be used.
Returns: The
Path
to the downloaded file.
-
urlretrieve_report
(url, size, total)¶ Default
urlretrieve()
log function.
-
-
class
network.
NetworkTool
¶ Implementation of
genvid.toolbox.NetworkTool