Infrastructure changes to launch pyconsole interpreter process

This commit is contained in:
Kovid Goyal 2010-09-20 21:32:29 -06:00
parent fe6d962bee
commit 3fff4da652
3 changed files with 17 additions and 9 deletions

View File

@ -22,13 +22,15 @@ class Worker(object):
have the environment variable :envvar:`CALIBRE_WORKER` set.
Useful attributes: ``is_alive``, ``returncode``
usefule methods: ``kill``
Useful methods: ``kill``
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
the call.
'''
exe_name = 'calibre-parallel'
@property
def osx_interpreter(self):
exe = os.path.basename(sys.executable)
@ -41,32 +43,33 @@ class Worker(object):
@property
def executable(self):
e = self.exe_name
if iswindows:
return os.path.join(os.path.dirname(sys.executable),
'calibre-parallel.exe' if isfrozen else \
'Scripts\\calibre-parallel.exe')
e+'.exe' if isfrozen else \
'Scripts\\%s.exe'%e)
if isnewosx:
return os.path.join(sys.console_binaries_path, 'calibre-parallel')
return os.path.join(sys.console_binaries_path, e)
if isosx:
if not isfrozen: return 'calibre-parallel'
if not isfrozen: return e
contents = os.path.join(self.osx_contents_dir,
'console.app', 'Contents')
return os.path.join(contents, 'MacOS', self.osx_interpreter)
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):
return c
return 'calibre-parallel'
return e
@property
def gui_executable(self):
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:
return os.path.join(self.osx_contents_dir,

View File

@ -80,8 +80,12 @@ def main():
if isosx and 'CALIBRE_WORKER_ADDRESS' not in os.environ:
# On some OS X computers launchd apparently tries to
# launch the last run process from the bundle
# so launch the gui as usual
from calibre.gui2.main import main as gui_main
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']))
key = unhexlify(os.environ['CALIBRE_WORKER_KEY'])
resultf = unhexlify(os.environ['CALIBRE_WORKER_RESULT'])

View File

@ -47,6 +47,7 @@ class Prepender(object): # {{{
self.console.cursor_pos = self.opos
# }}}
class Console(QTextEdit):
running = pyqtSignal()