forked from openlp/openlp
Add zeroconf to AppVeyor and setup.py, broadcast on all valid interfaces, quit the thread properly
This commit is contained in:
parent
a3b8a56da2
commit
50fcc9b5d5
@ -23,6 +23,8 @@
|
|||||||
The :mod:`~openlp.core.api.zeroconf` module runs a Zerconf server so that OpenLP can advertise the
|
The :mod:`~openlp.core.api.zeroconf` module runs a Zerconf server so that OpenLP can advertise the
|
||||||
RESTful API for devices on the network to discover.
|
RESTful API for devices on the network to discover.
|
||||||
"""
|
"""
|
||||||
|
import logging
|
||||||
|
import re
|
||||||
import socket
|
import socket
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
@ -33,6 +35,11 @@ from openlp.core.common.registry import Registry
|
|||||||
from openlp.core.common.settings import Settings
|
from openlp.core.common.settings import Settings
|
||||||
from openlp.core.threading import ThreadWorker, run_thread
|
from openlp.core.threading import ThreadWorker, run_thread
|
||||||
|
|
||||||
|
# Skip names like "docker0", "tun0", "loopback_0", etc
|
||||||
|
INTERFACE_FILTER = re.compile('loopback|docker|tun', re.IGNORECASE)
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ZeroconfWorker(ThreadWorker):
|
class ZeroconfWorker(ThreadWorker):
|
||||||
"""
|
"""
|
||||||
@ -76,6 +83,7 @@ class ZeroconfWorker(ThreadWorker):
|
|||||||
zc.unregister_service(http_info)
|
zc.unregister_service(http_info)
|
||||||
zc.unregister_service(ws_info)
|
zc.unregister_service(ws_info)
|
||||||
zc.close()
|
zc.close()
|
||||||
|
self.quit.emit()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
"""
|
"""
|
||||||
@ -91,11 +99,11 @@ def start_zeroconf():
|
|||||||
# When we're running tests, just skip this set up if this flag is set
|
# When we're running tests, just skip this set up if this flag is set
|
||||||
if Registry().get_flag('no_web_server'):
|
if Registry().get_flag('no_web_server'):
|
||||||
return
|
return
|
||||||
ifaces = get_local_ip4()
|
|
||||||
for key in iter(ifaces):
|
|
||||||
address = ifaces.get(key)['ip']
|
|
||||||
break
|
|
||||||
http_port = Settings().value('api/port')
|
http_port = Settings().value('api/port')
|
||||||
ws_port = Settings().value('api/websocket port')
|
ws_port = Settings().value('api/websocket port')
|
||||||
worker = ZeroconfWorker(address, http_port, ws_port)
|
for name, interface in get_local_ip4().items():
|
||||||
run_thread(worker, 'api_zeroconf')
|
log.debug('Interface {name}: {interface}'.format(name=name, interface=interface))
|
||||||
|
if not INTERFACE_FILTER.search(name):
|
||||||
|
# Only advertise on real interfaces
|
||||||
|
worker = ZeroconfWorker(interface['ip'], http_port, ws_port)
|
||||||
|
run_thread(worker, 'api_zeroconf_{name}'.format(name=name))
|
||||||
|
@ -18,7 +18,7 @@ environment:
|
|||||||
|
|
||||||
install:
|
install:
|
||||||
# Install dependencies from pypi
|
# Install dependencies from pypi
|
||||||
- "%PYTHON%\\python.exe -m pip install sqlalchemy alembic appdirs chardet beautifulsoup4 lxml Mako mysql-connector-python pytest mock pyodbc psycopg2 pypiwin32 websockets asyncio waitress six webob requests QtAwesome PyQt5 PyQtWebEngine pymediainfo PyMuPDF QDarkStyle python-vlc Pyro4"
|
- "%PYTHON%\\python.exe -m pip install sqlalchemy alembic appdirs chardet beautifulsoup4 lxml Mako mysql-connector-python pytest mock pyodbc psycopg2 pypiwin32 websockets asyncio waitress six webob requests QtAwesome PyQt5 PyQtWebEngine pymediainfo PyMuPDF QDarkStyle python-vlc Pyro4 zeroconf"
|
||||||
|
|
||||||
build: off
|
build: off
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user