Fix encoding of __file__ for windows

review816002
This commit is contained in:
Cédric Krier committed 2013-04-27 12:01:43 +02:00
1 parent 5d6b83ea37
commit 531f4f0e22
2 files changed
+6 -2

No files matched your search

+4 -1
View File
@@ -1,6 +1,7 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import os
import sys
import logging
from lxml import etree
from trytond.model import ModelView, ModelSQL, fields
@@ -100,7 +101,9 @@ class View(ModelSQL, ModelView):
key = (cls.__name__, type_)
rng = cls._get_rng_cache.get(key)
if rng is None:
rng_name = os.path.join(os.path.dirname(__file__), type_ + '.rng')
rng_name = os.path.join(os.path.dirname(
unicode(__file__, sys.getfilesystemencoding())),
type_ + '.rng')
rng = etree.fromstring(open(rng_name).read())
cls._get_rng_cache.set(key, rng)
return rng
+2 -1
View File
@@ -78,7 +78,8 @@ def exec_command_pipe(name, *args):
def file_open(name, mode="r", subdir='modules'):
"""Open a file from the root dir, using a subdir folder."""
from trytond.modules import EGG_MODULES
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
root_path = os.path.dirname(os.path.dirname(os.path.abspath(
unicode(__file__, sys.getfilesystemencoding()))))
egg_name = False
if subdir == 'modules':