From 92f044689d32c6f7bdfbfdb333013a6c419e254a Mon Sep 17 00:00:00 2001 From: Andy Kittner Date: Tue, 25 Jun 2013 22:23:30 +0200 Subject: [PATCH] Fix issues when starting portable from a non-ascii path --- extras/openslides_gui/gui.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) mode change 100644 => 100755 extras/openslides_gui/gui.py diff --git a/extras/openslides_gui/gui.py b/extras/openslides_gui/gui.py old mode 100644 new mode 100755 index 2d69fef8f..060eab6a2 --- a/extras/openslides_gui/gui.py +++ b/extras/openslides_gui/gui.py @@ -25,7 +25,8 @@ ungettext = lambda msg1, msg2, n: _translations.ungettext(msg1, msg2, n) def get_data_path(*args): - return os.path.join(os.path.dirname(__file__), "data", *args) + path = openslides.main.fs2unicode(__file__) + return os.path.join(os.path.dirname(path), "data", *args) class RunCmdEvent(wx.PyCommandEvent): @@ -82,6 +83,15 @@ class RunCommandControl(wx.Panel): cmd = [sys.executable, "-u", "-m", "openslides.main"] cmd.extend(args) + + # XXX: subprocess on windows only handles byte strings + # with python3 this will hopefully no longer be the case + fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() + cmd = [ + x.encode(fs_encoding) if isinstance(x, unicode) else x + for x in cmd + ] + creationflags = getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0) self.child_process = subprocess.Popen( cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, @@ -682,7 +692,8 @@ def main(): lang = locale.getdefaultlocale()[0] if lang: global _translations - localedir = os.path.dirname(openslides.__file__) + localedir = openslides.main.fs2unicode(openslides.__file__) + localedir = os.path.dirname(localedir) localedir = os.path.join(localedir, "locale") _translations = gettext.translation( "django", localedir, [lang], fallback=True)