Method¶
- class getmac.getmac.Method[source]¶
Bases:
objectBase class defining a method to get a MAC address. Subclasses should implement the
test()andget()methods.Attributes Summary
The valid platform identifier strings, used to match methods to the appropriate platform.
The type of method, e.g. does it get the MAC of a interface.
If the method makes a network request as part of the check.
Platforms supported by a method.
Marks the method as unable to be used, e.g. if there was a runtime error indicating the method won't work on the current platform.
Methods Summary
get(arg)Core logic of the method that performs the lookup.
test()Low-impact test that the method is feasible, e.g. a command exists.
Attributes Documentation
- VALID_PLATFORM_NAMES: Final[set[str]] = {'android', 'darwin', 'dragonfly', 'freebsd', 'hp-ux', 'linux', 'netbsd', 'openbsd', 'other', 'sunos', 'windows', 'wsl'}¶
The valid platform identifier strings, used to match methods to the appropriate platform.
- method_type: str = ''¶
The type of method, e.g. does it get the MAC of a interface.
Allowed values:
ip
ip4
ip6
iface
default_iface
- unusable: bool = False¶
Marks the method as unable to be used, e.g. if there was a runtime error indicating the method won’t work on the current platform.
Methods Documentation
- get(arg)[source]¶
Core logic of the method that performs the lookup.
Warning
If the method itself fails to function an exception will be raised! (for instance, if some command arguments are invalid, or there’s an internal error with the command, or a bug in the code).
- Parameters:
arg (
str) – What the method should get, such as an IP address or interface name. In the case ofdefault_ifacemethods, this is not used and defaults to an empty string.- Return type:
- Returns:
The raw value the technique found, or
Noneif nothing was found. It isn’t cleaned up, so it may not be a lowercase colon-separated MAC (get_mac_address()runs it throughclean_mac()). Fordefault_ifacemethods, it’s the name of an interface instead of a MAC.