From d6e4ce275f3c26ebb9e3bc5f6b9b42d3a30a7e29 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 6 Jun 2009 10:27:57 -0700 Subject: [PATCH] Launching GUI from Terminal now works correctly in OS X --- installer/osx/freeze.py | 14 ++++---------- src/calibre/devices/usbms/device.py | 2 +- src/calibre/ebooks/epub/input.py | 2 +- src/calibre/utils/ipc/launch.py | 5 +++++ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/installer/osx/freeze.py b/installer/osx/freeze.py index f5e62c4649..06155d3c48 100644 --- a/installer/osx/freeze.py +++ b/installer/osx/freeze.py @@ -31,6 +31,7 @@ resources_dir = os.path.join(base_dir, 'Resources') frameworks_dir = os.path.join(base_dir, 'Frameworks') base_name = os.path.splitext(name)[0] python = os.path.join(base_dir, 'MacOS', 'python') +qt_plugins = os.path.join(os.path.realpath(base_dir), 'MacOS') loader_path = os.path.join(dirpath, base_name+'.py') loader = open(loader_path, 'w') site_packages = glob.glob(resources_dir+'/lib/python*/site-packages.zip')[0] @@ -46,9 +47,10 @@ print >>loader, '%(function)s()' loader.close() os.chmod(loader_path, 0700) os.environ['PYTHONHOME'] = resources_dir -os.environ['FC_CONFIG_DIR'] = os.path.join(resources_dir, 'fonts') +os.environ['FONTCONFIG_PATH'] = os.path.join(resources_dir, 'fonts') os.environ['MAGICK_HOME'] = os.path.join(frameworks_dir, 'ImageMagick') os.environ['DYLD_LIBRARY_PATH'] = os.path.join(frameworks_dir, 'ImageMagick', 'lib') +os.environ['QT_PLUGIN_PATH'] = qt_plugins args = [path, loader_path] + sys.argv[1:] os.execv(python, args) ''' @@ -259,19 +261,11 @@ _check_symlinks_prescript() dest = os.path.join(frameworks_dir, os.path.basename(f)) if os.path.exists(dest): os.remove(dest) - os.link(f, dest) + shutil.copyfile(f, dest) dst = os.path.join(resource_dir, 'fonts') if os.path.exists(dst): shutil.rmtree(dst) shutil.copytree('/usr/local/etc/fonts', dst, symlinks=False) - for x in os.listdir('/usr/local/etc/fonts'): - dst = os.path.join(frameworks_dir, x) - y = os.path.join('/usr/local/etc/fonts', x) - if os.path.isdir(dst): - if os.path.exists(dst): shutil.rmtree(dst) - shutil.copytree(y, dst) - else: - os.link(y, dst) print print 'Adding IPython' diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index d5dcf3e440..3d0d030cb8 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -504,7 +504,7 @@ class Device(DeviceConfig, DevicePlugin): def do_it(drives): for d in drives: try: - winutil.eject_drive(d) + winutil.eject_drive(bytes(d)[0]) except: pass diff --git a/src/calibre/ebooks/epub/input.py b/src/calibre/ebooks/epub/input.py index b748429725..3405e1ef4e 100644 --- a/src/calibre/ebooks/epub/input.py +++ b/src/calibre/ebooks/epub/input.py @@ -28,7 +28,7 @@ class EPUBInput(InputFormatPlugin): f.write(raw[1024:]) @classmethod - def process_ecryption(cls, encfile, opf, log): + def process_encryption(cls, encfile, opf, log): key = None m = re.search(r'(?i)(urn:uuid:[0-9a-f-]+)', open(opf, 'rb').read()) if m: diff --git a/src/calibre/utils/ipc/launch.py b/src/calibre/utils/ipc/launch.py index 2a578ed7d9..4aa8f684ad 100644 --- a/src/calibre/utils/ipc/launch.py +++ b/src/calibre/utils/ipc/launch.py @@ -108,6 +108,11 @@ class Worker(object): self._env['PYTHONHOME'] = resources self._env['MAGICK_HOME'] = os.path.join(fd, 'ImageMagick') self._env['DYLD_LIBRARY_PATH'] = os.path.join(fd, 'ImageMagick', 'lib') + self._env['FONTCONFIG_PATH'] = \ + os.path.join(os.path.realpath(resources), 'fonts') + self._env['QT_PLUGIN_PATH'] = \ + os.path.join(self.osx_contents_dir, 'MacOS') + if isfrozen and not (iswindows or isosx): self._env['LD_LIBRARY_PATH'] = getattr(sys, 'frozen_path') + ':'\ + os.environ.get('LD_LIBRARY_PATH', '')