Kaynağa Gözat

wxGUI/toolboxes: fix case when grass7 directory in home is missing

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56358 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 yıl önce
ebeveyn
işleme
81c540c379
1 değiştirilmiş dosya ile 20 ekleme ve 5 silme
  1. 20 5
      gui/wxpython/core/toolboxes.py

+ 20 - 5
gui/wxpython/core/toolboxes.py

@@ -39,6 +39,7 @@ from core.utils import GetSettingsPath
 from core.gcmd import GError
 
 import grass.script.task as gtask
+import grass.script.core as gcore
 from grass.script.core import ScriptError
 
 
@@ -122,14 +123,28 @@ def getMenuFile():
 
 def _setupToolboxes():
     """!Create 'toolboxes' directory if doesn't exist."""
-    path = os.path.join(GetSettingsPath(), 'toolboxes')
+    basePath = GetSettingsPath()
+    path = os.path.join(basePath, 'toolboxes')
+    if not os.path.exists(basePath):
+        return None
+
+    if _createPath(path):
+           return path
+    return None
+
+
+def _createPath(path):
+    """!Creates path (for toolboxes) if it doesn't exist'"""
     if not os.path.exists(path):
         try:
             os.mkdir(path)
-        except:
-            GError(_('Unable to create toolboxes directory.'))
-            return None
-    return path
+        except OSError, e:
+            # we cannot use GError or similar because the gui doesn''t start at all
+            gcore.warning('%(reason)s\n%(detail)s' % 
+                    ({'reason':_('Unable to create toolboxes directory.'),
+                      'detail': str(e)}))
+            return False
+    return True
 
 
 def toolboxes2menudata(userDefined=True):