Przeglądaj źródła

wxGUI: don't fail if .bash_history is not readable

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@43820 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 lat temu
rodzic
commit
efa4754e7e
1 zmienionych plików z 12 dodań i 6 usunięć
  1. 12 6
      gui/wxpython/gui_modules/goutput.py

+ 12 - 6
gui/wxpython/gui_modules/goutput.py

@@ -437,13 +437,19 @@ class GMConsole(wx.SplitterWindow):
         
         # update history file
         env = grass.gisenv()
-        fileHistory = open(os.path.join(env['GISDBASE'], env['LOCATION_NAME'], env['MAPSET'],
-                                        '.bash_history'), 'a')
-        cmdString = ' '.join(cmdlist)
         try:
-            fileHistory.write(cmdString + '\n')
-        finally:
-            fileHistory.close()
+            fileHistory = open(os.path.join(env['GISDBASE'], env['LOCATION_NAME'], env['MAPSET'],
+                                            '.bash_history'), 'a')
+        except IOError, e:
+            self.WriteError(str(e))
+            fileHistory = None
+
+        cmdString = ' '.join(cmdlist)
+        if fileHistory:
+            try:
+                fileHistory.write(cmdString + '\n')
+            finally:
+                fileHistory.close()
         
         # update history items
         if self.parent.GetName() == 'LayerManager':