File tree 4 files changed +31
-5
lines changed
4 files changed +31
-5
lines changed Original file line number Diff line number Diff line change
1
+ v9.2.0
2
+ ======
3
+
4
+ #4: Added support for macOS to ``jaraco.net.devices ``.
5
+
1
6
v9.1.0
2
7
======
3
8
Original file line number Diff line number Diff line change 1
1
import sys
2
2
import importlib
3
- import platform
4
3
5
4
from jaraco .context import ExceptionTrap
6
5
@@ -17,11 +16,8 @@ def pywin32_missing():
17
16
[
18
17
'jaraco/net/devices/linux.py' ,
19
18
'jaraco/net/devices/win32.py' ,
19
+ 'jaraco/net/devices/darwin.py' ,
20
20
]
21
- + [
22
- 'jaraco/net/devices/__init__.py' ,
23
- ]
24
- * (platform .system () == 'Darwin' )
25
21
+ [
26
22
# modules only import on Windows
27
23
'jaraco/net/dns.py' ,
Original file line number Diff line number Diff line change
1
+ import subprocess
2
+ import operator
3
+
4
+ import ifconfigparser
5
+
6
+ from .base import BaseManager
7
+
8
+
9
+ def if_config ():
10
+ cfg = subprocess .check_output (['ifconfig' ], text = True )
11
+ return ifconfigparser .IfconfigParser (cfg )
12
+
13
+
14
+ class Manager (BaseManager ):
15
+ def get_host_mac_addresses (self ):
16
+ return self ._iface_values ('mac_addr' )
17
+
18
+ def get_host_ip_addresses (self ):
19
+ return self ._iface_values ('ipv4_addr' )
20
+
21
+ @staticmethod
22
+ def _iface_values (key ):
23
+ ifaces = if_config ().get_interfaces ().values ()
24
+ return filter (None , map (operator .attrgetter (key ), ifaces ))
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ install_requires =
32
32
python-dateutil
33
33
pathvalidate
34
34
pywin32; sys_platform == 'win32' and python_version < "3.12"
35
+ ifconfig-parser; sys_platform == 'darwin'
35
36
jsonpickle != 3.0.0
36
37
37
38
[options.packages.find]
You can’t perform that action at this time.
0 commit comments