瀏覽代碼

wxGUI: attempt to fix launching script on Windows https://trac.osgeo.org/grass/ticket/2532

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@63997 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 10 年之前
父節點
當前提交
5e455b95e4
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      gui/wxpython/lmgr/frame.py

+ 10 - 2
gui/wxpython/lmgr/frame.py

@@ -43,7 +43,7 @@ if os.path.join(globalvar.ETCDIR, "python") not in sys.path:
 
 from grass.script          import core as grass
 
-from core.gcmd             import RunCommand, GError, GMessage, GException
+from core.gcmd             import RunCommand, GError, GMessage, EncodeString
 from core.settings         import UserSettings, GetDisplayVectSettings
 from core.utils            import SetAddOnPath, GetLayerNameFromCmd, command2ltype, _
 from gui_core.preferences  import MapsetAccess, PreferencesDialog
@@ -851,6 +851,14 @@ class GMFrame(wx.Frame):
         
         if not filename:
             return False
+        try:
+            filename_encoded = EncodeString(filename)
+        except UnicodeEncodeError:
+            GError(parent=self,
+                   message = _("Due to the limitations of your operating system, "
+                               "the script path cannot contain non-ascii characters. "
+                               "Please rename the script or move it to a different location."))
+            return
         
         if not os.path.exists(filename):
             GError(parent = self,
@@ -882,7 +890,7 @@ class GMFrame(wx.Frame):
         addonPath = os.getenv('GRASS_ADDON_PATH', [])
         if addonPath:
             addonPath = addonPath.split(os.pathsep)
-        dirName = os.path.dirname(filename)
+        dirName = os.path.dirname(filename_encoded)
         if dirName not in addonPath:
             addonPath.append(dirName)
             dlg = wx.MessageDialog(self,