[GRASS-SVN] r46913 - grass/branches/develbranch_6/gui/wxpython

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 1 06:22:01 EDT 2011


Author: martinl
Date: 2011-07-01 03:22:00 -0700 (Fri, 01 Jul 2011)
New Revision: 46913

Modified:
   grass/branches/develbranch_6/gui/wxpython/gis_set.py
Log:
wxGUI: complain about concurrent usage
      (merge r46911 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gis_set.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gis_set.py	2011-07-01 10:21:08 UTC (rev 46912)
+++ grass/branches/develbranch_6/gui/wxpython/gis_set.py	2011-07-01 10:22:00 UTC (rev 46913)
@@ -11,7 +11,7 @@
  - GListBox
  - StartUp
 
-(C) 2006-2010 by the GRASS Development Team
+(C) 2006-2011 by the GRASS Development Team
 
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -42,7 +42,7 @@
 
 from gui_modules import goutput
 from gui_modules.ghelp import HelpFrame
-from gui_modules.gcmd  import GMessage
+from gui_modules.gcmd  import GMessage, GError
 
 sys.stderr = codecs.getwriter('utf8')(sys.stderr)
 
@@ -590,10 +590,10 @@
         self.listOfMapsets = utils.GetListOfMapsets(self.gisdbase, location)
         
         self.lbmapsets.Clear()
-
+        
         # disable mapset with denied permission
         locationName = os.path.basename(location)
-
+        
         try:
             ret = gcmd.RunCommand('g.mapset',
                                   read = True,
@@ -602,7 +602,7 @@
                                   gisdbase = self.gisdbase)
             
             if ret == '':
-                raise gcmd.GError(_("No mapsets available in location <%s>") % locationName)
+                GError(_("No mapsets available in location <%s>") % locationName)
             
             for line in ret.splitlines():
                 self.listOfMapsetsSelectable += line.split(' ')
@@ -735,15 +735,24 @@
 
     def OnStart(self, event):
         """'Start GRASS' button clicked"""
+        dbase    = self.tgisdbase.GetValue()
+        location = self.listOfLocations[self.lblocations.GetSelection()]
+        mapset   = self.listOfMapsets[self.lbmapsets.GetSelection()]
+        
+        lockfile = os.path.join(dbase, location, mapset, '.gislock')
+        if os.path.isfile(lockfile):
+            GError(_("GRASS is already running in selected mapset <%(mapset)s>\n"
+                     "(File %(lock)s found).\n\n"
+                     "Concurrent use not allowed.") % { 'mapset' : mapset, 'lock' : lockfile },
+                   parent = self)
+            return
+        
         gcmd.RunCommand("g.gisenv",
-                        set = "GISDBASE=%s" % \
-                            self.tgisdbase.GetValue())
+                        set = "GISDBASE=%s" % dbase)
         gcmd.RunCommand("g.gisenv",
-                        set = "LOCATION_NAME=%s" % \
-                            self.listOfLocations[self.lblocations.GetSelection()])
+                        set = "LOCATION_NAME=%s" % location)
         gcmd.RunCommand("g.gisenv",
-                        set = "MAPSET=%s" % \
-                            self.listOfMapsets[self.lbmapsets.GetSelection()])
+                        set = "MAPSET=%s" % mapset)
         
         self.Destroy()
         sys.exit(0)



More information about the grass-commit mailing list