From 5cf742755244dfa13eccc9afd38c335a87cbc9ff Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Mon, 7 Aug 2023 18:31:54 -0700 Subject: [PATCH 1/3] Remove android specific code path for getting all addresses. Keep android error handling to prevent breakages. --- zeroconf.py | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/zeroconf.py b/zeroconf.py index f98b6153..082bdc12 100644 --- a/zeroconf.py +++ b/zeroconf.py @@ -1721,40 +1721,12 @@ def find(cls, zc=None, timeout=5, interfaces=InterfaceChoice.All): return tuple(sorted(listener.found_services)) -if "ANDROID_ARGUMENT" in os.environ: - - from jnius import autoclass - - AndroidString = autoclass("java.lang.String") - - def get_all_addresses(): - addresses = [] - try: - NetworkInterface = autoclass("java.net.NetworkInterface") - Inet4Address = autoclass("java.net.Inet4Address") - ifaces = NetworkInterface.getNetworkInterfaces() - while ifaces and ifaces.hasMoreElements(): - iface = ifaces.nextElement() - ips = iface.getInetAddresses() - while ips and ips.hasMoreElements(): - ip = ips.nextElement() - # There are no methods for checking IP address type, so check object type. - address = ip.getHostAddress() - if isinstance(ip, Inet4Address): - addresses.append(address) - except Exception as e: - return [] - - return 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 and not addr.ip.startswith("169.254"))) +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 and not addr.ip.startswith("169.254"))) def normalize_interface_choice(choice): From 75fd7b38e714caeddf46e44888d9c6e2f9be392b Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Tue, 8 Aug 2023 14:24:45 -0700 Subject: [PATCH 2/3] Update version --- zeroconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zeroconf.py b/zeroconf.py index 082bdc12..831b0422 100644 --- a/zeroconf.py +++ b/zeroconf.py @@ -51,7 +51,7 @@ __author__ = "Paul Scott-Murphy, William McBrine" __maintainer__ = "Learning Equality " -__version__ = "0.19.16" +__version__ = "0.19.17" __license__ = "LGPL" From 7a2eb158fe03dff07130b6d77f0223a9cdcfd0e9 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Tue, 8 Aug 2023 14:26:07 -0700 Subject: [PATCH 3/3] Update publishing code to use Python 3.9 --- .github/workflows/python-publish.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index c60021e9..1c6336b7 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -15,14 +15,14 @@ on: jobs: deploy: - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: - python-version: 2.7 + python-version: 3.9 - name: Install dependencies run: | python -m pip install --upgrade pip