get_by_method¶
- getmac.getmac.get_by_method(method_type, arg='', network_request=True)[source]¶
Query for a MAC using a specific method.
- Parameters:
method_type (
str) – the type of lookup being performed. Allowed values are:ip4,ip6,iface,default_ifacearg (
str) – Argument to pass to the method, e.g. an interface name or IP addressnetwork_request (
bool) – if methods that make network requests should be included (those methods that have the attributenetwork_requestset toTrue)
- Return type:
- Returns:
The raw value the method found (a MAC that hasn’t been cleaned up, or for
default_iface, the name of an interface), orNoneif nothing was found- Raises:
RuntimeError – if no method can be used for the given method type, e.g. none of them match the platform, or they all failed their test.