mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Attempt to cope with accented characters in host names when starting MDNS
This commit is contained in:
parent
8e3ba79234
commit
34c17c479c
@ -6,6 +6,9 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import socket, time, atexit
|
import socket, time, atexit
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from calibre.utils.filenames import ascii_text
|
||||||
|
from calibre import force_unicode
|
||||||
|
|
||||||
_server = None
|
_server = None
|
||||||
|
|
||||||
def get_all_ips():
|
def get_all_ips():
|
||||||
@ -82,12 +85,16 @@ def start_server():
|
|||||||
def create_service(desc, type, port, properties, add_hostname, use_ip_address=None):
|
def create_service(desc, type, port, properties, add_hostname, use_ip_address=None):
|
||||||
port = int(port)
|
port = int(port)
|
||||||
try:
|
try:
|
||||||
hostname = socket.gethostname().partition('.')[0]
|
hostname = ascii_text(force_unicode(socket.gethostname())).partition('.')[0]
|
||||||
except:
|
except:
|
||||||
hostname = 'Unknown'
|
hostname = 'Unknown'
|
||||||
|
|
||||||
if add_hostname:
|
if add_hostname:
|
||||||
desc += ' (on %s)'%hostname
|
try:
|
||||||
|
desc += b' (on %s)'%hostname
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
if use_ip_address:
|
if use_ip_address:
|
||||||
local_ip = use_ip_address
|
local_ip = use_ip_address
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user