From b90734f1e22ba89dd5f335666e1829a81158f58c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Jan 2021 20:51:50 +0200 Subject: [PATCH] List multicast DNS services only when PY3 --- platformio/util.py | 13 +++++++++---- setup.py | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/platformio/util.py b/platformio/util.py index c3d0da3c..6b1af886 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -24,7 +24,6 @@ from functools import wraps from glob import glob import click -import zeroconf from platformio import __version__, compat, exception, proc from platformio.compat import PY2, WINDOWS @@ -165,6 +164,9 @@ def get_logical_devices(): def get_mdns_services(): compat.ensure_python3() + # pylint: disable=import-outside-toplevel + import zeroconf + class mDNSListener(object): def __init__(self): self._zc = zeroconf.Zeroconf(interfaces=zeroconf.InterfaceChoice.All) @@ -186,9 +188,6 @@ def get_mdns_services(): def __exit__(self, etype, value, traceback): self._zc.close() - def remove_service(self, zc, type_, name): - pass - def add_service(self, zc, type_, name): try: assert zeroconf.service_type_name(name) @@ -203,6 +202,12 @@ def get_mdns_services(): if s: self._found_services.append(s) + def remove_service(self, zc, type_, name): + pass + + def update_service(self, zc, type_, name): + pass + def get_services(self): return self._found_services diff --git a/setup.py b/setup.py index 577c2951..2aab992a 100644 --- a/setup.py +++ b/setup.py @@ -36,9 +36,11 @@ minimal_requirements = [ "requests==2.*", "semantic_version==2.8.*", "tabulate==0.8.*", - "zeroconf==%s" % ("0.19.*" if PY2 else "0.28.*"), ] +if not PY2: + minimal_requirements.append("zeroconf==0.28.*") + home_requirements = [ "aiofiles==0.6.*", "json-rpc==1.13.*",