Skip to content

Commit

Permalink
mdns -> zeroconf
Browse files Browse the repository at this point in the history
  • Loading branch information
linknum23 authored and Lohrer committed Jan 2, 2024
1 parent 61b4664 commit b31f6d2
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion amplipi/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 3 additions & 3 deletions amplipi/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion amplipi/mdns.py → amplipi/zeroconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""AmpliPi MDNS service advertisement"""
"""AmpliPi zeroconf service advertisement"""

import logging
from multiprocessing.synchronize import Event as SyncEvent
Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/test_mdns.py → tests/test_zeroconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b31f6d2

Please sign in to comment.