[GRASS-SVN] r46885 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 1 03:26:49 EDT 2011


Author: martinl
Date: 2011-07-01 00:26:49 -0700 (Fri, 01 Jul 2011)
New Revision: 46885

Modified:
   grass/trunk/gui/wxpython/gui_modules/gselect.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: define GetSettingsPath()


Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2011-07-01 07:15:43 UTC (rev 46884)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2011-07-01 07:26:49 UTC (rev 46885)
@@ -1075,9 +1075,9 @@
             self.sourceMap['pro'] = idx
         
         if self.ogr:
-            self.settingsFile = os.path.join(os.path.expanduser("~"), '.grass7', 'wxOGR')
+            self.settingsFile = os.path.join(utils.GetSettingsPath(), 'wxOGR')
         else:
-            self.settingsFile = os.path.join(os.path.expanduser("~"), '.grass7', 'wxGDAL')
+            self.settingsFile = os.path.join(utils.GetSettingsPath(), 'wxGDAL')
         
         self._settings = self._loadSettings()
         self.settingsChoice = wx.Choice(parent = self, id = wx.ID_ANY)

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2011-07-01 07:15:43 UTC (rev 46884)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2011-07-01 07:26:49 UTC (rev 46885)
@@ -61,7 +61,7 @@
     """!Generic class where to store settings"""
     def __init__(self):
         # settings file
-        self.filePath = os.path.join(os.path.expanduser("~"), '.grass7', 'wx')
+        self.filePath = os.path.join(utils.GetSettingsPath(), 'wx')
         
         # key/value separator
         self.sep = ';'
@@ -766,7 +766,7 @@
         
         home = os.path.expanduser("~") # MS Windows fix ?
         
-        dirPath = os.path.join(home, '.grass7')
+        dirPath = utils.GetSettingsPath()
         if os.path.exists(dirPath) == False:
             try:
                 os.mkdir(dirPath)

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2011-07-01 07:15:43 UTC (rev 46884)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2011-07-01 07:26:49 UTC (rev 46885)
@@ -752,3 +752,12 @@
             }
     
     return formats
+
+def GetSettingsPath():
+    """!Get full path to the settings directory
+    """
+    version = int(grass.version()['version'].split('.', 1)[0])
+    if sys.platform == 'win32':
+        return os.path.join(os.getenv('APPDATA'), '.grass%d' % version)
+    
+    return os.path.join(os.getenv('HOME'), '.grass%d' % version)



More information about the grass-commit mailing list