Settings

class getmac.variables.Settings[source]

Bases: VarsClass

User-configurable settings.

Attributes Summary

ARP_TIMEOUT

How long to keep checking the ARP table (IPv4) or NDP list (IPv6) for a host, in seconds, after sending the UDP packet to populate it (see PORT).

COMMAND_TIMEOUT

How long to wait for a command that getmac runs (e.g. arp or ipconfig.exe) to finish, in seconds.

DEBUG

Debugging level.

FORCE_METHOD

Force a specific method to be used for all lookups.

OVERRIDE_PLATFORM

User-configurable override to force a specific platform.

PORT

UDP port to use for populating the ARP table (IPv4) or NDP list (IPv6) when looking up MACs for hosts or IPs.

Attributes Documentation

ARP_TIMEOUT: float = 0

How long to keep checking the ARP table (IPv4) or NDP list (IPv6) for a host, in seconds, after sending the UDP packet to populate it (see PORT).

The host’s entry is only added once it replies, which often takes longer than getmac takes to check the table. If it isn’t there, getmac checks again with short, growing delays until the host is found or this much time has passed. Lookups of hosts that don’t reply take this much longer. 0 (the default) checks once, without waiting.

This doesn’t apply when getmac sends an ARP request itself and waits for the reply instead (ArpingHost or CtypesHost).

COMMAND_TIMEOUT: float | None = 15.0

How long to wait for a command that getmac runs (e.g. arp or ipconfig.exe) to finish, in seconds. A command that takes longer is stopped, and the method that ran it is treated as failed, so the next method is tried.

This keeps a lookup from hanging forever on a command that never exits. Commands usually finish in well under a second, but some, such as arp without -n on macOS, can be slow due to DNS lookups. None or 0 waits for as long as the command takes.

DEBUG: int = 0

Debugging level. Increased value => more output. 4 is roughly the highest.

FORCE_METHOD: str = ''

Force a specific method to be used for all lookups. Used for debugging and testing.

OVERRIDE_PLATFORM: str = ''

User-configurable override to force a specific platform.

Methods for this platform are used instead of the methods for the detected platform, PLATFORM. Use a platform identifier such as "linux" or "wsl", or any value returned by platform.system(), such as "Darwin". Case and surrounding whitespace are ignored. An empty string (the default) means no override.

PORT: int = 55555

UDP port to use for populating the ARP table (IPv4) or NDP list (IPv6) when looking up MACs for hosts or IPs.