1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-12 15:27:14 +03:00

Allow executable and plugins to be run from non-ASCII paths

Fixes #234
This commit is contained in:
Jonathan Harris 2017-08-19 15:43:06 +01:00
parent 66b9699b45
commit 929bd82684
4 changed files with 9 additions and 9 deletions

View File

@ -123,7 +123,7 @@ class Config:
if not isdir(self.plugin_dir):
mkdir(self.plugin_dir)
self.internal_plugin_dir = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable), pardir, 'Library', 'plugins')) or join(dirname(__file__), 'plugins')
self.internal_plugin_dir = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable.decode(sys.getfilesystemencoding())), pardir, 'Library', 'plugins')) or join(dirname(__file__), 'plugins')
self.default_journal_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], 'Frontier Developments', 'Elite Dangerous')
@ -131,7 +131,7 @@ class Config:
self.home = expanduser('~')
self.respath = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable), pardir, 'Resources')) or dirname(__file__)
self.respath = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable.decode(sys.getfilesystemencoding())), pardir, 'Resources')) or dirname(__file__)
if not getattr(sys, 'frozen', False):
# Don't use Python's settings if interactive
@ -185,7 +185,7 @@ class Config:
if not isdir(self.plugin_dir):
mkdir(self.plugin_dir)
self.internal_plugin_dir = join(dirname(getattr(sys, 'frozen', False) and sys.executable or __file__), 'plugins')
self.internal_plugin_dir = join(dirname(getattr(sys, 'frozen', False) and sys.executable.decode(sys.getfilesystemencoding()) or __file__), u'plugins')
# expanduser in Python 2 on Windows doesn't handle non-ASCII - http://bugs.python.org/issue13207
self.home = KnownFolderPath(FOLDERID_Profile) or u'\\'
@ -195,7 +195,7 @@ class Config:
self.default_interaction_dir = join(KnownFolderPath(FOLDERID_LocalAppData), 'Frontier Developments', 'Elite Dangerous', 'CommanderHistory')
self.respath = dirname(getattr(sys, 'frozen', False) and sys.executable or __file__)
self.respath = dirname(getattr(sys, 'frozen', False) and sys.executable.decode(sys.getfilesystemencoding()) or __file__)
self.identifier = applongname

View File

@ -127,9 +127,9 @@ class Translations:
def respath(self):
if getattr(sys, 'frozen', False):
if platform=='darwin':
return normpath(join(dirname(sys.executable), os.pardir, 'Resources'))
return normpath(join(dirname(sys.executable.decode(sys.getfilesystemencoding())), os.pardir, 'Resources'))
else:
return join(dirname(sys.executable), 'L10n')
return join(dirname(sys.executable.decode(sys.getfilesystemencoding())), 'L10n')
elif __file__:
return join(dirname(__file__), 'L10n')
else:

View File

@ -39,9 +39,9 @@ class Plugin(object):
self.module = None # None for disabled plugins.
if loadfile:
sys.stdout.write('loading plugin %s from "%s"\n' % (name, loadfile.encode('utf-8')))
sys.stdout.write(('loading plugin %s from "%s"\n' % (name, loadfile)).encode('utf-8'))
with open(loadfile, 'rb') as plugfile:
module = imp.load_module('plugin_%s' % name, plugfile, loadfile.encode(sys.getfilesystemencoding()),
module = imp.load_module('plugin_%s' % name.encode('ascii', 'replace'), plugfile, loadfile.encode(sys.getfilesystemencoding()),
('.py', 'r', imp.PY_SOURCE))
newname = module.plugin_start()
self.name = newname and unicode(newname) or name

View File

@ -50,7 +50,7 @@ elif sys.platform=='darwin':
def __init__(self, master):
try:
objc.loadBundle('Sparkle', globals(), join(dirname(sys.executable), os.pardir, 'Frameworks', 'Sparkle.framework'))
objc.loadBundle('Sparkle', globals(), join(dirname(sys.executable.decode(sys.getfilesystemencoding())), os.pardir, 'Frameworks', 'Sparkle.framework'))
self.updater = SUUpdater.sharedUpdater()
except:
# can't load framework - not frozen or not included in app bundle?