Skip to content

Commit

Permalink
Considering adding support for darwin. Broken due to sanketsudake/ifc…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Dec 5, 2022
1 parent 371d0d6 commit f160d86
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions jaraco/net/devices/darwin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ifparser

from .base import BaseManager


def if_config():
cfg = subprocess.check_output(['ifconfig'])
return ifparser.Ifcfg(cfg)


class Manager(BaseManager):
def get_host_mac_addresses(self):
return map(operator.attrgetter('hwaddr'), self._get_ifaces())

def get_host_ip_addresses(self):
return map(operator.attrgetter('ip'), self._get_ifaces())

@staticmethod
def _get_ifaces():
cfg = if_config()
return map(cfg.get_interface, cfg.interfaces)
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ install_requires =
python-dateutil
pathvalidate
pywin32; sys_platform == 'win32' and python_version < "3.12"
ifparser; sys_platform == 'darwin'
jsonpickle != 3.0.0

[options.packages.find]
Expand Down

0 comments on commit f160d86

Please sign in to comment.