mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Infrastructure changes to launch pyconsole interpreter process
This commit is contained in:
parent
fe6d962bee
commit
3fff4da652
@ -22,13 +22,15 @@ class Worker(object):
|
|||||||
have the environment variable :envvar:`CALIBRE_WORKER` set.
|
have the environment variable :envvar:`CALIBRE_WORKER` set.
|
||||||
|
|
||||||
Useful attributes: ``is_alive``, ``returncode``
|
Useful attributes: ``is_alive``, ``returncode``
|
||||||
usefule methods: ``kill``
|
Useful methods: ``kill``
|
||||||
|
|
||||||
To launch child simply call the Worker object. By default, the child's
|
To launch child simply call the Worker object. By default, the child's
|
||||||
output is redirected to an on disk file, the path to which is returned by
|
output is redirected to an on disk file, the path to which is returned by
|
||||||
the call.
|
the call.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
exe_name = 'calibre-parallel'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def osx_interpreter(self):
|
def osx_interpreter(self):
|
||||||
exe = os.path.basename(sys.executable)
|
exe = os.path.basename(sys.executable)
|
||||||
@ -41,32 +43,33 @@ class Worker(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def executable(self):
|
def executable(self):
|
||||||
|
e = self.exe_name
|
||||||
if iswindows:
|
if iswindows:
|
||||||
return os.path.join(os.path.dirname(sys.executable),
|
return os.path.join(os.path.dirname(sys.executable),
|
||||||
'calibre-parallel.exe' if isfrozen else \
|
e+'.exe' if isfrozen else \
|
||||||
'Scripts\\calibre-parallel.exe')
|
'Scripts\\%s.exe'%e)
|
||||||
if isnewosx:
|
if isnewosx:
|
||||||
return os.path.join(sys.console_binaries_path, 'calibre-parallel')
|
return os.path.join(sys.console_binaries_path, e)
|
||||||
|
|
||||||
if isosx:
|
if isosx:
|
||||||
if not isfrozen: return 'calibre-parallel'
|
if not isfrozen: return e
|
||||||
contents = os.path.join(self.osx_contents_dir,
|
contents = os.path.join(self.osx_contents_dir,
|
||||||
'console.app', 'Contents')
|
'console.app', 'Contents')
|
||||||
return os.path.join(contents, 'MacOS', self.osx_interpreter)
|
return os.path.join(contents, 'MacOS', self.osx_interpreter)
|
||||||
|
|
||||||
if isfrozen:
|
if isfrozen:
|
||||||
return os.path.join(getattr(sys, 'frozen_path'), 'calibre-parallel')
|
return os.path.join(getattr(sys, 'frozen_path'), e)
|
||||||
|
|
||||||
c = os.path.join(sys.executables_location, 'calibre-parallel')
|
c = os.path.join(sys.executables_location, e)
|
||||||
if os.access(c, os.X_OK):
|
if os.access(c, os.X_OK):
|
||||||
return c
|
return c
|
||||||
return 'calibre-parallel'
|
return e
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gui_executable(self):
|
def gui_executable(self):
|
||||||
if isnewosx:
|
if isnewosx:
|
||||||
return os.path.join(sys.binaries_path, 'calibre-parallel')
|
return os.path.join(sys.binaries_path, self.exe_name)
|
||||||
|
|
||||||
if isfrozen and isosx:
|
if isfrozen and isosx:
|
||||||
return os.path.join(self.osx_contents_dir,
|
return os.path.join(self.osx_contents_dir,
|
||||||
|
@ -80,8 +80,12 @@ def main():
|
|||||||
if isosx and 'CALIBRE_WORKER_ADDRESS' not in os.environ:
|
if isosx and 'CALIBRE_WORKER_ADDRESS' not in os.environ:
|
||||||
# On some OS X computers launchd apparently tries to
|
# On some OS X computers launchd apparently tries to
|
||||||
# launch the last run process from the bundle
|
# launch the last run process from the bundle
|
||||||
|
# so launch the gui as usual
|
||||||
from calibre.gui2.main import main as gui_main
|
from calibre.gui2.main import main as gui_main
|
||||||
return gui_main(['calibre'])
|
return gui_main(['calibre'])
|
||||||
|
if 'CALIBRE_LAUNCH_INTERPRETER' in os.environ:
|
||||||
|
from calibre.utils.pyconsole.interpreter import main
|
||||||
|
return main()
|
||||||
address = cPickle.loads(unhexlify(os.environ['CALIBRE_WORKER_ADDRESS']))
|
address = cPickle.loads(unhexlify(os.environ['CALIBRE_WORKER_ADDRESS']))
|
||||||
key = unhexlify(os.environ['CALIBRE_WORKER_KEY'])
|
key = unhexlify(os.environ['CALIBRE_WORKER_KEY'])
|
||||||
resultf = unhexlify(os.environ['CALIBRE_WORKER_RESULT'])
|
resultf = unhexlify(os.environ['CALIBRE_WORKER_RESULT'])
|
||||||
|
@ -47,6 +47,7 @@ class Prepender(object): # {{{
|
|||||||
self.console.cursor_pos = self.opos
|
self.console.cursor_pos = self.opos
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class Console(QTextEdit):
|
class Console(QTextEdit):
|
||||||
|
|
||||||
running = pyqtSignal()
|
running = pyqtSignal()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user