[GRASS-SVN] r49748 - grass/trunk/general/g.mapset

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Dec 14 10:32:16 EST 2011


Author: mmetz
Date: 2011-12-14 07:32:16 -0800 (Wed, 14 Dec 2011)
New Revision: 49748

Modified:
   grass/trunk/general/g.mapset/main.c
Log:
report mapset to switch to; find out who's busy there

Modified: grass/trunk/general/g.mapset/main.c
===================================================================
--- grass/trunk/general/g.mapset/main.c	2011-12-14 15:31:06 UTC (rev 49747)
+++ grass/trunk/general/g.mapset/main.c	2011-12-14 15:32:16 UTC (rev 49748)
@@ -155,16 +155,18 @@
     ret = G__mapset_permissions2(gisdbase_new, location_new, mapset_new);
     switch (ret) {
     case 0:
-	G_fatal_error(_("You don't have permission to use this mapset"));
+	G_fatal_error(_("You don't have permission to use the mapset <%s>"),
+	              mapset_new);
 	break;
     case -1:
 	if (flag.add->answer == TRUE) {
-	    G_debug(2, "Mapset %s doesn't exist, attempting to create it",
+	    G_debug(2, "Mapset <%s> doesn't exist, attempting to create it",
 		    mapset_new);
 	    G_make_mapset(gisdbase_new, location_new, mapset_new);
 	}
 	else
-	    G_fatal_error(_("The mapset does not exist. Use -c flag to create it."));
+	    G_fatal_error(_("Mapset <%s> does not exist. Use -c flag to create it."),
+	                  mapset_new);
 	break;
     default:
 	break;
@@ -179,17 +181,22 @@
 
     sprintf(path, "%s/.gislock", mapset_new_path);
     G_debug(2, path);
-
+    
     ret = G_spawn(lock_prog, lock_prog, path, gis_lock, NULL);
     G_debug(2, "lock result = %d", ret);
     G_free(lock_prog);
 
     /* Warning: the value returned by system() is not that returned by exit() in executed program
      *          e.g. exit(1) -> 256 (multiplied by 256) */
-    if (ret != 0)
-	G_fatal_error(_("<%s> is currently running GRASS in selected mapset "
-			"or lock file cannot be checked"),
-		      G_whoami());
+    if (ret != 0) {
+	/* .gislock does not exist */
+	if (access(path, F_OK) != 0)
+	    G_fatal_error(_("Lock file of mapset <%s> cannot be checked"),
+			   mapset_new);
+	else
+	    G_fatal_error(_("<%s> is currently running GRASS in selected mapset <%s>"),
+		      G_owner(path), mapset_new);
+    }
 
     /* Clean temporary directory */
     sprintf(path, "%s/etc/clean_temp", G_gisbase());



More information about the grass-commit mailing list