[GRASS-SVN] r56358 - grass/trunk/gui/wxpython/core
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 22 08:29:25 PDT 2013
Author: annakrat
Date: 2013-05-22 08:29:25 -0700 (Wed, 22 May 2013)
New Revision: 56358
Modified:
grass/trunk/gui/wxpython/core/toolboxes.py
Log:
wxGUI/toolboxes: fix case when grass7 directory in home is missing
Modified: grass/trunk/gui/wxpython/core/toolboxes.py
===================================================================
--- grass/trunk/gui/wxpython/core/toolboxes.py 2013-05-21 21:52:12 UTC (rev 56357)
+++ grass/trunk/gui/wxpython/core/toolboxes.py 2013-05-22 15:29:25 UTC (rev 56358)
@@ -39,6 +39,7 @@
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 _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):
More information about the grass-commit
mailing list