mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add infrastructure for developing embedded reader in Content Server
This commit is contained in:
parent
bcd38778f5
commit
649ce9605a
3385
resources/content_server/monocle.js
Normal file
3385
resources/content_server/monocle.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
__all__ = [
|
||||
'pot', 'translations', 'get_translations', 'iso639',
|
||||
'build', 'build_pdf2xml',
|
||||
'build', 'build_pdf2xml', 'server',
|
||||
'gui',
|
||||
'develop', 'install',
|
||||
'resources',
|
||||
@ -35,6 +35,9 @@ from setup.extensions import Build, BuildPDF2XML
|
||||
build = Build()
|
||||
build_pdf2xml = BuildPDF2XML()
|
||||
|
||||
from setup.server import Server
|
||||
server = Server()
|
||||
|
||||
from setup.install import Develop, Install, Sdist
|
||||
develop = Develop()
|
||||
install = Install()
|
||||
|
48
setup/server.py
Normal file
48
setup/server.py
Normal file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import subprocess, tempfile, os, time
|
||||
|
||||
from setup import Command
|
||||
|
||||
class Server(Command):
|
||||
|
||||
description = 'Run the calibre server in development mode conveniently'
|
||||
|
||||
MONOCLE_PATH = '../monocle'
|
||||
|
||||
def rebuild_monocole(self):
|
||||
subprocess.check_call(['sprocketize', '-C', self.MONOCLE_PATH,
|
||||
'-I', 'src', 'src/monocle.js'],
|
||||
stdout=open('resources/content_server/monocle.js', 'wb'))
|
||||
|
||||
def launch_server(self, log):
|
||||
self.rebuild_monocole()
|
||||
p = subprocess.Popen(['calibre-server', '--develop'],
|
||||
stderr=subprocess.STDOUT, stdout=log)
|
||||
return p
|
||||
|
||||
def run(self, opts):
|
||||
tdir = tempfile.gettempdir()
|
||||
logf = os.path.join(tdir, 'calibre-server.log')
|
||||
log = open(logf, 'ab')
|
||||
print 'Server log available at:', logf
|
||||
|
||||
while True:
|
||||
print 'Starting server...'
|
||||
p = self.launch_server(log)
|
||||
try:
|
||||
raw_input('Press Enter to kill/restart server. Ctrl+C to quit: ')
|
||||
except:
|
||||
break
|
||||
else:
|
||||
while p.returncode is None:
|
||||
p.terminate()
|
||||
time.sleep(0.1)
|
||||
p.kill()
|
||||
print
|
||||
|
Loading…
x
Reference in New Issue
Block a user