7258: Ensure that resource paths are set correctly when they include Unicode characters.
This commit is contained in:
parent
8e164e29a2
commit
efa3741579
@ -17,7 +17,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
from __future__ import unicode_literals
|
||||||
import sys
|
import sys
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
@ -27,7 +27,7 @@ _hdlr = logging.StreamHandler()
|
|||||||
_hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: %(message)s"))
|
_hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: %(message)s"))
|
||||||
LOG.addHandler(_hdlr)
|
LOG.addHandler(_hdlr)
|
||||||
|
|
||||||
from ..constfunc import get_env_var
|
from ..constfunc import get_env_var, conv_to_unicode
|
||||||
|
|
||||||
class ResourcePath(object):
|
class ResourcePath(object):
|
||||||
"""
|
"""
|
||||||
@ -50,8 +50,8 @@ class ResourcePath(object):
|
|||||||
if self.initialized:
|
if self.initialized:
|
||||||
return
|
return
|
||||||
|
|
||||||
resource_file = os.path.join(os.path.abspath(os.path.dirname(__file__)),
|
resource_file = os.path.join(os.path.abspath(os.path.dirname(
|
||||||
'resource-path')
|
conv_to_unicode(__file__))), 'resource-path')
|
||||||
installed = os.path.exists(resource_file)
|
installed = os.path.exists(resource_file)
|
||||||
if installed:
|
if installed:
|
||||||
test_path = os.path.join("gramps", "authors.xml")
|
test_path = os.path.join("gramps", "authors.xml")
|
||||||
@ -65,7 +65,7 @@ class ResourcePath(object):
|
|||||||
try:
|
try:
|
||||||
with io.open(resource_file, encoding='utf-8',
|
with io.open(resource_file, encoding='utf-8',
|
||||||
errors='strict') as fp:
|
errors='strict') as fp:
|
||||||
resource_path = fp.readline()
|
resource_path = conv_to_unicode(fp.readline())
|
||||||
except UnicodeError as err:
|
except UnicodeError as err:
|
||||||
LOG.exception("Encoding error while parsing resource path", err)
|
LOG.exception("Encoding error while parsing resource path", err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user