mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Better error message when failing to start BonJour plugin because IP address could not be determined
This commit is contained in:
parent
84394aee3e
commit
faca264f18
@ -104,7 +104,7 @@ class PluginPool(object):
|
|||||||
try:
|
try:
|
||||||
plugin.start(self.loop)
|
plugin.start(self.loop)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.loop.log.exception('Failed to start plugin: %s', self.plugin_name(plugin))
|
self.loop.log.exception('Failed to start plugin:', self.plugin_name(plugin))
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
for w in self.workers:
|
for w in self.workers:
|
||||||
@ -116,7 +116,7 @@ class PluginPool(object):
|
|||||||
try:
|
try:
|
||||||
w.plugin.stop()
|
w.plugin.stop()
|
||||||
except Exception:
|
except Exception:
|
||||||
self.loop.log.exception('Failed to stop plugin: %s', self.plugin_name(w.plugin))
|
self.loop.log.exception('Failed to stop plugin:', self.plugin_name(w.plugin))
|
||||||
for w in self.workers:
|
for w in self.workers:
|
||||||
left = wait_till - monotonic()
|
left = wait_till - monotonic()
|
||||||
if left > 0:
|
if left > 0:
|
||||||
|
@ -42,6 +42,7 @@ class AllIpAddressesGetter(Thread):
|
|||||||
# print 'slept'
|
# print 'slept'
|
||||||
_all_ip_addresses = self.get_all_ips()
|
_all_ip_addresses = self.get_all_ips()
|
||||||
|
|
||||||
|
|
||||||
_ip_address_getter_thread = None
|
_ip_address_getter_thread = None
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ def verify_ipV4_address(ip_address):
|
|||||||
pass
|
pass
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
_ext_ip = None
|
_ext_ip = None
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ def get_external_ip():
|
|||||||
if _ext_ip is None:
|
if _ext_ip is None:
|
||||||
from calibre.utils.ip_routing import get_default_route_src_address
|
from calibre.utils.ip_routing import get_default_route_src_address
|
||||||
try:
|
try:
|
||||||
_ext_ip = get_default_route_src_address()
|
_ext_ip = get_default_route_src_address() or _get_external_ip()
|
||||||
except Exception:
|
except Exception:
|
||||||
_ext_ip = _get_external_ip()
|
_ext_ip = _get_external_ip()
|
||||||
return _ext_ip
|
return _ext_ip
|
||||||
@ -138,6 +140,8 @@ def create_service(desc, type, port, properties, add_hostname, use_ip_address=No
|
|||||||
local_ip = use_ip_address
|
local_ip = use_ip_address
|
||||||
else:
|
else:
|
||||||
local_ip = get_external_ip()
|
local_ip = get_external_ip()
|
||||||
|
if not local_ip:
|
||||||
|
raise ValueError('Failed to determine local IP address to advertise via BonJour')
|
||||||
type = type+'.local.'
|
type = type+'.local.'
|
||||||
from calibre.utils.Zeroconf import ServiceInfo
|
from calibre.utils.Zeroconf import ServiceInfo
|
||||||
return ServiceInfo(type, desc+'.'+type,
|
return ServiceInfo(type, desc+'.'+type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user