[Python-modules-commits] [python-zeroconf] 02/08: Switch from netifaces to psutil

Ruben Undheim rubund-guest at moszumanska.debian.org
Wed Apr 13 19:10:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch upstream
in repository python-zeroconf.

commit dd907f2eed3768a3c1e3889af84b5dbeb700a1e7
Author: Jakub Stasiak <jakub at stasiak.at>
Date:   Tue Dec 1 01:40:09 2015 +0100

    Switch from netifaces to psutil
    
    netifaces installation on Python 3.x is broken and there doesn't seem to
    be any plan to release a working version on PyPI, instead of using its
    fork I decided to use another package providing the required
    information.
    
    This closes https://github.com/jstasiak/python-zeroconf/issues/31
    
    [1] https://bitbucket.org/al45tair/netifaces/issues/13/0104-install-is-broken-on-python-3x
---
 requirements-dev.txt |  2 +-
 setup.py             |  2 +-
 zeroconf.py          | 11 ++++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/requirements-dev.txt b/requirements-dev.txt
index bc92af5..adce92b 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -7,8 +7,8 @@ flake8-blind-except
 # Upper bound because of https://github.com/public/flake8-import-order/issues/42
 flake8-import-order>=0.4.0, <0.6.0
 mock
-netifaces
 nose
 pep8==1.5.7
 pep8-naming
+psutil
 six
diff --git a/setup.py b/setup.py
index 54e05e1..8e43bc5 100755
--- a/setup.py
+++ b/setup.py
@@ -52,7 +52,7 @@ setup(
     ],
     install_requires=[
         'enum-compat',
-        'netifaces',
+        'psutil',
         'six',
     ],
 )
diff --git a/zeroconf.py b/zeroconf.py
index bf2402e..c1601d2 100644
--- a/zeroconf.py
+++ b/zeroconf.py
@@ -32,7 +32,7 @@ import threading
 import time
 from functools import reduce
 
-import netifaces
+import psutil
 from six import binary_type, indexbytes, int2byte, iteritems, text_type
 from six.moves import xrange
 
@@ -1271,10 +1271,11 @@ HOST_ONLY_NETWORK_MASK = '255.255.255.255'
 
 def get_all_addresses(address_family):
     return list(set(
-        addr['addr']
-        for iface in netifaces.interfaces()
-        for addr in netifaces.ifaddresses(iface).get(address_family, [])
-        if addr.get('netmask') != HOST_ONLY_NETWORK_MASK
+        nic.address
+        for iface, nics in psutil.net_if_addrs().items()
+        for nic in nics
+        if nic.family == address_family and
+        nic.netmask != HOST_ONLY_NETWORK_MASK
     ))
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-zeroconf.git



More information about the Python-modules-commits mailing list