From b31f6d2135eaa1b651bb154ab5adc9978266bc62 Mon Sep 17 00:00:00 2001 From: Lincoln Lorenz Date: Tue, 2 Jan 2024 12:41:30 -0500 Subject: [PATCH] mdns -> zeroconf --- .github/workflows/python-app.yml | 2 +- amplipi/__init__.py | 3 ++- amplipi/asgi.py | 6 +++--- amplipi/{mdns.py => zeroconf.py} | 2 +- scripts/test | 2 +- tests/context.py | 6 +++--- tests/{test_mdns.py => test_zeroconf.py} | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) rename amplipi/{mdns.py => zeroconf.py} (99%) rename tests/{test_mdns.py => test_zeroconf.py} (95%) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index cfd308e07..9441d1e85 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -44,7 +44,7 @@ jobs: pytest tests/test_ctrl.py -vvv -k doubly_missing_config pytest tests/test_rest.py -vvv -k 'not _live' --cov=./ --cov-report=xml pytest tests/test_auth.py -vvv - pytest tests/test_mdns.py -vvv + pytest tests/test_zeroconf.py -vvv - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/amplipi/__init__.py b/amplipi/__init__.py index 44a8787e6..19aa25d93 100755 --- a/amplipi/__init__.py +++ b/amplipi/__init__.py @@ -1,3 +1,4 @@ """ AmpliPi """ # TODO: remove "rt" -__all__ = ["app", "asgi", "ctrl", "display", "eeprom", "extras", "hw", "mdns", "models", "rt", "streams", "utils"] +__all__ = ["app", "asgi", "auth", "ctrl", "defaults", "display", "eeprom", + "extras", "hw", "models", "mpris", "rt", "streams", "utils", "zeroconf"] diff --git a/amplipi/asgi.py b/amplipi/asgi.py index 7ffd316e3..f19282d37 100755 --- a/amplipi/asgi.py +++ b/amplipi/asgi.py @@ -25,7 +25,7 @@ from multiprocessing import Process, Event import uvicorn import amplipi.app -from amplipi import mdns +from amplipi import zeroconf MOCK_CTRL = os.environ.get('MOCK_CTRL', 'False').lower() == 'true' MOCK_STREAMS = os.environ.get('MOCK_STREAMS', 'False').lower() == 'true' @@ -39,13 +39,13 @@ # NOTE: Zeroconf advertisements need to be done as a separate process to avoid blocking the # webserver startup since behind the scenes zeroconf makes its own event loop. zc_event = Event() -zc_reg = Process(target=mdns.advertise_service, args=(PORT, zc_event)) +zc_reg = Process(target=zeroconf.advertise_service, args=(PORT, zc_event)) zc_reg.start() @application.on_event('shutdown') def on_shutdown(): - """ Notify the mdns advertisement to shutdown""" + """ Notify the zeroconf advertisement to shutdown""" zc_event.set() zc_reg.join() diff --git a/amplipi/mdns.py b/amplipi/zeroconf.py similarity index 99% rename from amplipi/mdns.py rename to amplipi/zeroconf.py index bcff796bd..09850e0e5 100644 --- a/amplipi/mdns.py +++ b/amplipi/zeroconf.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -"""AmpliPi MDNS service advertisement""" +"""AmpliPi zeroconf service advertisement""" import logging from multiprocessing.synchronize import Event as SyncEvent diff --git a/scripts/test b/scripts/test index 6da7bb944..02413cb7c 100755 --- a/scripts/test +++ b/scripts/test @@ -27,7 +27,7 @@ pytest tests/test_ctrl.py -vvv -k doubly_missing_config pytest tests/test_rest.py -vvv -k 'not _live' pytest tests/test_auth.py -vvv -pytest tests/test_mdns.py -vvv +pytest tests/test_zeroconf.py -vvv # Live tests require some amplipi streams to be setup, which means real audio diff --git a/tests/context.py b/tests/context.py index 5dd732765..c412bcb85 100644 --- a/tests/context.py +++ b/tests/context.py @@ -4,12 +4,12 @@ import amplipi import amplipi.app +import amplipi.auth import amplipi.ctrl +import amplipi.defaults import amplipi.hw -import amplipi.mdns import amplipi.models import amplipi.rt # TODO: remove import amplipi.streams import amplipi.utils -import amplipi.auth -import amplipi.defaults +import amplipi.zeroconf diff --git a/tests/test_mdns.py b/tests/test_zeroconf.py similarity index 95% rename from tests/test_mdns.py rename to tests/test_zeroconf.py index d0f2cf21f..a616941ec 100644 --- a/tests/test_mdns.py +++ b/tests/test_zeroconf.py @@ -22,7 +22,7 @@ def on_service_state_change(zeroconf: Zeroconf, service_type: str, name: str, st # advertise amplipi-api service (start this before the listener to verify it can be found after advertisement) event = Event() - zc_reg = Process(target=amplipi.mdns.advertise_service, args=(FAKE_PORT, event)) + zc_reg = Process(target=amplipi.zeroconf.advertise_service, args=(FAKE_PORT, event)) zc_reg.start() sleep(4) # wait for a bit to make sure the service is started