mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-05 09:53:33 +03:00
Fix loading plugins from non-ASCII paths
Workaround for http://bugs.python.org/issue9425 Fixes #219
This commit is contained in:
parent
f07be949af
commit
320b1977c2
30
plug.py
30
plug.py
@ -5,6 +5,9 @@ import os
|
|||||||
import imp
|
import imp
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
if __debug__:
|
||||||
|
from traceback import print_exc
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -46,14 +49,17 @@ def load_plugins():
|
|||||||
try:
|
try:
|
||||||
sys.stdout.write("loading plugin {}\n".format(plugname))
|
sys.stdout.write("loading plugin {}\n".format(plugname))
|
||||||
with open(found[plugname], "rb") as plugfile:
|
with open(found[plugname], "rb") as plugfile:
|
||||||
plugmod = imp.load_module(plugname, plugfile, found[plugname],
|
plugmod = imp.load_module(plugname, plugfile, found[plugname].encode(sys.getfilesystemencoding()),
|
||||||
(".py", "r", imp.PY_SOURCE))
|
(".py", "r", imp.PY_SOURCE))
|
||||||
if "plugin_start" in dir(plugmod):
|
if "plugin_start" in dir(plugmod):
|
||||||
newname = plugmod.plugin_start()
|
newname = plugmod.plugin_start()
|
||||||
PLUGINS[newname and unicode(newname) or plugname] = plugmod
|
PLUGINS[newname and unicode(newname) or plugname] = plugmod
|
||||||
|
|
||||||
except Exception as plugerr:
|
except Exception as plugerr:
|
||||||
sys.stderr.write('%s: %s\n' % (plugname, plugerr)) # appears in %TMP%/EDMarketConnector.log in packaged Windows app
|
if __debug__:
|
||||||
|
print_exc()
|
||||||
|
else:
|
||||||
|
sys.stderr.write('%s: %s\n' % (plugname, plugerr)) # appears in %TMP%/EDMarketConnector.log in packaged Windows app
|
||||||
|
|
||||||
imp.release_lock()
|
imp.release_lock()
|
||||||
|
|
||||||
@ -107,7 +113,10 @@ def notify_prefs_changed():
|
|||||||
try:
|
try:
|
||||||
prefs_changed()
|
prefs_changed()
|
||||||
except Exception as plugerr:
|
except Exception as plugerr:
|
||||||
print plugerr
|
if __debug__:
|
||||||
|
print_exc()
|
||||||
|
else:
|
||||||
|
sys.stderr.write('%s: %s\n' % (plugname, plugerr))
|
||||||
|
|
||||||
|
|
||||||
def notify_journal_entry(cmdr, system, station, entry, state):
|
def notify_journal_entry(cmdr, system, station, entry, state):
|
||||||
@ -130,7 +139,10 @@ def notify_journal_entry(cmdr, system, station, entry, state):
|
|||||||
else:
|
else:
|
||||||
journal_entry(cmdr, system, station, dict(entry), dict(state))
|
journal_entry(cmdr, system, station, dict(entry), dict(state))
|
||||||
except Exception as plugerr:
|
except Exception as plugerr:
|
||||||
print plugerr
|
if __debug__:
|
||||||
|
print_exc()
|
||||||
|
else:
|
||||||
|
sys.stderr.write('%s: %s\n' % (plugname, plugerr))
|
||||||
|
|
||||||
|
|
||||||
def notify_system_changed(timestamp, system, coordinates):
|
def notify_system_changed(timestamp, system, coordinates):
|
||||||
@ -151,7 +163,10 @@ def notify_system_changed(timestamp, system, coordinates):
|
|||||||
else:
|
else:
|
||||||
system_changed(timestamp, system, coordinates)
|
system_changed(timestamp, system, coordinates)
|
||||||
except Exception as plugerr:
|
except Exception as plugerr:
|
||||||
print plugerr
|
if __debug__:
|
||||||
|
print_exc()
|
||||||
|
else:
|
||||||
|
sys.stderr.write('%s: %s\n' % (plugname, plugerr))
|
||||||
|
|
||||||
|
|
||||||
def notify_newdata(data):
|
def notify_newdata(data):
|
||||||
@ -166,4 +181,7 @@ def notify_newdata(data):
|
|||||||
try:
|
try:
|
||||||
cmdr_data(data)
|
cmdr_data(data)
|
||||||
except Exception as plugerr:
|
except Exception as plugerr:
|
||||||
print plugerr
|
if __debug__:
|
||||||
|
print_exc()
|
||||||
|
else:
|
||||||
|
sys.stderr.write('%s: %s\n' % (plugname, plugerr))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user