FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Catch import error on Android for ifaddr. by rtibbles · Pull Request #11 · learningequality/python-zeroconf-py2compat · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
14 changes: 12 additions & 2 deletions zeroconf.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,21 @@
# Use ifaddr instead of ifcfg in order to ensure that we are always
# able to read outgoing addresses. ifcfg fails to do so on Windows
# in a non-English locale. This is critical for many of our users.
import ifaddr
# On Android if certain so files are not properly bundled, this can
# lead to an import error, so we catch it so that we can carry on with
# our own Android specific code.
try:
import ifaddr
except ImportError:
ifaddr = None
from six import binary_type, indexbytes, int2byte, iteritems, text_type
from six.moves import xrange

import enum_compat as enum

__author__ = "Paul Scott-Murphy, William McBrine"
__maintainer__ = "Jamie Alexandre <jamie@learningequality.org>"
__version__ = "0.19.11"
__version__ = "0.19.12"
__license__ = "LGPL"


Expand Down Expand Up @@ -1738,6 +1744,10 @@ def get_all_addresses():
else:

def get_all_addresses():
if ifaddr is None:
# This should never happen, as we have only seen this happen on Android
# but better to be safe than sorry.
return []
return list(set(addr.ip for iface in ifaddr.get_adapters() for addr in iface.ips if addr.is_IPv4))


Expand Down

Back | FazBrowse Home | New Git URL