mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1094063 (Problem Disconneting Wirless Connection)
This commit is contained in:
commit
16d793049f
@ -17,7 +17,7 @@ def ascii_text(orig):
|
|||||||
ascii = udc.decode(orig)
|
ascii = udc.decode(orig)
|
||||||
except:
|
except:
|
||||||
if isinstance(orig, unicode):
|
if isinstance(orig, unicode):
|
||||||
ascii = orig.encode('ascii', 'replace')
|
orig = orig.encode('ascii', 'replace')
|
||||||
ascii = orig.decode(preferred_encoding,
|
ascii = orig.decode(preferred_encoding,
|
||||||
'replace').encode('ascii', 'replace')
|
'replace').encode('ascii', 'replace')
|
||||||
return ascii
|
return ascii
|
||||||
|
@ -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 += ' (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