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.
|
||||
|
||||
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,
|
||||
|
@ -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'])
|
||||
|
@ -47,6 +47,7 @@ class Prepender(object): # {{{
|
||||
self.console.cursor_pos = self.opos
|
||||
# }}}
|
||||
|
||||
|
||||
class Console(QTextEdit):
|
||||
|
||||
running = pyqtSignal()
|
||||
|
Loading…
x
Reference in New Issue
Block a user