mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:...
This commit is contained in:
parent
fd3c5bb7f5
commit
ff7969051e
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
HTTP server for remote access to the calibre database.
|
HTTP server for remote access to the calibre database.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sys, textwrap, operator, os, re, logging, subprocess
|
import sys, textwrap, operator, os, re, logging
|
||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -933,7 +933,11 @@ class Reaper(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while 1:
|
while 1:
|
||||||
self.zeroconf.wait(10 * 1000)
|
try:
|
||||||
|
self.zeroconf.wait(10 * 1000)
|
||||||
|
except TypeError: # By Kovid
|
||||||
|
globals()['_GLOBAL_DONE'] = 1
|
||||||
|
return
|
||||||
if globals()['_GLOBAL_DONE']:
|
if globals()['_GLOBAL_DONE']:
|
||||||
return
|
return
|
||||||
now = currentTimeMillis()
|
now = currentTimeMillis()
|
||||||
|
@ -41,7 +41,7 @@ def publish(desc, type, port, properties=None, add_hostname=True):
|
|||||||
'''
|
'''
|
||||||
port = int(port)
|
port = int(port)
|
||||||
server = start_server()
|
server = start_server()
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname().partition('.')[0]
|
||||||
if add_hostname:
|
if add_hostname:
|
||||||
desc += ' (on %s)'%hostname
|
desc += ' (on %s)'%hostname
|
||||||
local_ip = get_external_ip()
|
local_ip = get_external_ip()
|
||||||
@ -58,40 +58,3 @@ def stop_server():
|
|||||||
global _server
|
global _server
|
||||||
if _server is not None:
|
if _server is not None:
|
||||||
_server.close()
|
_server.close()
|
||||||
|
|
||||||
'''
|
|
||||||
class Publish(object):
|
|
||||||
|
|
||||||
def __init__(self, desc, name, port, txt=''):
|
|
||||||
self.desc = desc
|
|
||||||
self.name = name
|
|
||||||
self.port = port
|
|
||||||
self.txt = txt
|
|
||||||
|
|
||||||
def start(self):
|
|
||||||
if iswindows:
|
|
||||||
return
|
|
||||||
if isosx:
|
|
||||||
args = ['dns-sd', self.desc, self.name, '.', self.port]
|
|
||||||
else:
|
|
||||||
args = ['avahi-publish-service', self.desc, self.name, self.port]
|
|
||||||
if self.txt:
|
|
||||||
args.append(self.txt)
|
|
||||||
|
|
||||||
self.process = subprocess.Popen(args)
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
if iswindows:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
process = getattr(self, 'process', None)
|
|
||||||
if process is not None:
|
|
||||||
process.poll()
|
|
||||||
if process.returncode is not None:
|
|
||||||
process.terminate()
|
|
||||||
process.poll()
|
|
||||||
if process.returncode is not None:
|
|
||||||
process.kill()
|
|
||||||
|
|
||||||
def publish(desc, name, port, txt):
|
|
||||||
'''
|
|
Loading…
x
Reference in New Issue
Block a user