[GRASS-SVN] r46585 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 7 12:15:26 EDT 2011
Author: martinl
Date: 2011-06-07 09:15:26 -0700 (Tue, 07 Jun 2011)
New Revision: 46585
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
Log:
bugfix #1383 (wxGUI crashes if settings file .grasswx6 does not exist)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2011-06-07 13:40:28 UTC (rev 46584)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2011-06-07 16:15:26 UTC (rev 46585)
@@ -693,11 +693,19 @@
"""!Read settings from file to dict"""
if settings is None:
settings = self.userSettings
-
+
+ if not os.path.exists(filename):
+ return
+
try:
- file = open(filename, "r")
+ fd = open(filename, "r")
+ except IOError:
+ sys.stderr.write(_("Unable to read settings file <%s>\n") % filename)
+ return
+
+ try:
line = ''
- for line in file.readlines():
+ for line in fd.readlines():
line = line.rstrip('%s' % os.linesep)
group, key = line.split(self.sep)[0:2]
kv = line.split(self.sep)[2:]
@@ -717,14 +725,14 @@
idx += 2
except ValueError, e:
print >> sys.stderr, _("Error: Reading settings from file <%(file)s> failed.\n"
- " Details: %(detail)s\n"
- " Line: '%(line)s'") % { 'file' : filename,
- 'detail' : e,
- 'line' : line }
- file.close()
+ "\t\tDetails: %(detail)s\n"
+ "\t\tLine: '%(line)s'\n") % { 'file' : filename,
+ 'detail' : e,
+ 'line' : line }
+ fd.close()
+
+ fd.close()
- file.close()
-
def SaveToFile(self, settings = None):
"""!Save settings to the file"""
if settings is None:
More information about the grass-commit
mailing list