backport [7fdf0f] and [6836db] from master
This commit is contained in:
parent
659433dd82
commit
016b779316
@ -135,7 +135,10 @@ if sys.version_info[0] < 3:
|
|||||||
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(
|
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(
|
||||||
unicode(__file__, sys.getfilesystemencoding())), os.pardir))
|
unicode(__file__, sys.getfilesystemencoding())), os.pardir))
|
||||||
|
|
||||||
VERSION += get_git_revision(ROOT_DIR)
|
git_revision = get_git_revision(ROOT_DIR)
|
||||||
|
if sys.platform == 'win32' and git_revision == "":
|
||||||
|
git_revision = get_git_revision(os.path.split(ROOT_DIR)[1])
|
||||||
|
VERSION += git_revision
|
||||||
#VERSION += "-1"
|
#VERSION += "-1"
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1134,7 +1134,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
|||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
key= str(key)
|
key= str(key)
|
||||||
else:
|
else:
|
||||||
key = str(tuple(str(k) for k in key))
|
key = str(tuple(k.encode('utf-8') for k in key))
|
||||||
if isinstance(key, UNITYPE):
|
if isinstance(key, UNITYPE):
|
||||||
key = key.encode('utf-8')
|
key = key.encode('utf-8')
|
||||||
if not self.readonly:
|
if not self.readonly:
|
||||||
|
@ -54,7 +54,7 @@ _ = glocale.translation.gettext
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from ..config import config
|
from ..config import config
|
||||||
from . import PluginRegister, ImportPlugin, ExportPlugin, DocGenPlugin
|
from . import PluginRegister, ImportPlugin, ExportPlugin, DocGenPlugin
|
||||||
from ..constfunc import STRTYPE
|
from ..constfunc import STRTYPE, win
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -256,9 +256,36 @@ class BasePluginManager(object):
|
|||||||
try:
|
try:
|
||||||
module = __import__(pdata.mod_name)
|
module = __import__(pdata.mod_name)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
LOG.warning('Plugin error: %s', err)
|
# Python3 on Windows work with unicode in sys.path
|
||||||
|
# but they are mbcs encode for checking validity
|
||||||
|
if (sys.version_info[0] >= 3) and win():
|
||||||
|
# we don't want to load Gramps core plugin like this
|
||||||
|
# only 3rd party plugins
|
||||||
|
if "gramps" in pdata.fpath:
|
||||||
|
try:
|
||||||
|
sys.path.insert(0, ".")
|
||||||
|
oldwd = os.getcwd()
|
||||||
|
os.chdir(pdata.fpath)
|
||||||
|
module = __import__(pdata.mod_name)
|
||||||
|
os.chdir(oldwd)
|
||||||
|
sys.path.pop(0)
|
||||||
|
except ValueError as err:
|
||||||
|
LOG.warning('Plugin error: %s', err)
|
||||||
|
else:
|
||||||
|
LOG.warning('Plugin error: %s', err)
|
||||||
except ImportError as err:
|
except ImportError as err:
|
||||||
LOG.warning('Plugin error: %s', err)
|
# Python2 on Windows not work with unicode in sys.path
|
||||||
|
# but module can be loaded from current directory
|
||||||
|
if (sys.version_info[0] < 3) and win():
|
||||||
|
try:
|
||||||
|
oldwd = os.getcwd()
|
||||||
|
os.chdir(pdata.fpath)
|
||||||
|
module = __import__(pdata.mod_name)
|
||||||
|
os.chdir(oldwd)
|
||||||
|
except ImportError as err:
|
||||||
|
LOG.warning('Plugin error: %s', err)
|
||||||
|
else:
|
||||||
|
LOG.warning('Plugin error: %s', err)
|
||||||
sys.path.pop(0)
|
sys.path.pop(0)
|
||||||
else:
|
else:
|
||||||
print("WARNING: module cannot be loaded")
|
print("WARNING: module cannot be loaded")
|
||||||
|
@ -1082,10 +1082,9 @@ class PluginRegister(object):
|
|||||||
lenpd = len(self.__plugindata)
|
lenpd = len(self.__plugindata)
|
||||||
full_filename = os.path.join(dir, filename)
|
full_filename = os.path.join(dir, filename)
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
full_filename = full_filename.encode(glocale.getfilesystemencoding())
|
|
||||||
fd = open(full_filename, "r")
|
fd = open(full_filename, "r")
|
||||||
else:
|
else:
|
||||||
fd = io.open(full_filename, 'r', encoding = 'utf-8')
|
fd = io.open(full_filename, 'r')
|
||||||
stream = fd.read()
|
stream = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
if os.path.exists(os.path.join(os.path.dirname(full_filename),
|
if os.path.exists(os.path.join(os.path.dirname(full_filename),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user