[GRASS-SVN] r73153 - in grass/trunk/gui/wxpython: . startup

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Aug 23 20:05:13 PDT 2018


Author: wenzeslaus
Date: 2018-08-23 20:05:13 -0700 (Thu, 23 Aug 2018)
New Revision: 73153

Added:
   grass/trunk/gui/wxpython/startup/guiutils.py
Modified:
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/startup/utils.py
Log:
wxGUI/startup: file to separate GUI-dependent utils (now only db/loc/mapset setting)

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2018-08-24 02:45:39 UTC (rev 73152)
+++ grass/trunk/gui/wxpython/gis_set.py	2018-08-24 03:05:13 UTC (rev 73153)
@@ -39,6 +39,7 @@
 from core.utils import GetListOfLocations, GetListOfMapsets
 from startup.utils import (
     get_lockfile_if_present, get_possible_database_path)
+from startup.guiutils import SetSessionMapset
 from location_wizard.dialogs import RegionDef
 from gui_core.dialogs import TextEntryDialog
 from gui_core.widgets import GenericValidator, StaticWrapText
@@ -877,12 +878,7 @@
             for line in ret.splitlines():
                 self.listOfMapsetsSelectable += line.split(' ')
         else:
-            RunCommand("g.gisenv",
-                       set="GISDBASE=%s" % self.gisdbase)
-            RunCommand("g.gisenv",
-                       set="LOCATION_NAME=%s" % locationName)
-            RunCommand("g.gisenv",
-                       set="MAPSET=PERMANENT")
+            self.SetLocation(self.gisdbase, locationName, "PERMANENT")
             # first run only
             self.listOfMapsetsSelectable = copy.copy(self.listOfMapsets)
 
@@ -1110,12 +1106,7 @@
         self.ExitSuccessfully()
 
     def SetLocation(self, dbase, location, mapset):
-        RunCommand("g.gisenv",
-                   set="GISDBASE=%s" % dbase)
-        RunCommand("g.gisenv",
-                   set="LOCATION_NAME=%s" % location)
-        RunCommand("g.gisenv",
-                   set="MAPSET=%s" % mapset)
+        SetSessionMapset(dbase, location, mapset)
 
     def _getDefaultMapsetName(self):
         """Returns default name for mapset."""

Added: grass/trunk/gui/wxpython/startup/guiutils.py
===================================================================
--- grass/trunk/gui/wxpython/startup/guiutils.py	                        (rev 0)
+++ grass/trunk/gui/wxpython/startup/guiutils.py	2018-08-24 03:05:13 UTC (rev 73153)
@@ -0,0 +1,24 @@
+"""
+ at package startup.guiutils
+
+ at brief General GUI-dependent utilities for GUI startup of GRASS GIS
+
+(C) 2018 by Vaclav Petras 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.
+
+ at author Vaclav Petras <wenzeslaus gmail com>
+
+This is for code which depend on something from GUI (wx or wxGUI). 
+"""
+
+
+from core.gcmd import RunCommand
+
+
+def SetSessionMapset(database, location, mapset):
+    """Sets database, location and mapset for the current session"""
+    RunCommand("g.gisenv", set="GISDBASE=%s" % database)
+    RunCommand("g.gisenv", set="LOCATION_NAME=%s" % location)
+    RunCommand("g.gisenv", set="MAPSET=%s" % mapset)


Property changes on: grass/trunk/gui/wxpython/startup/guiutils.py
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-python
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: grass/trunk/gui/wxpython/startup/utils.py
===================================================================
--- grass/trunk/gui/wxpython/startup/utils.py	2018-08-24 02:45:39 UTC (rev 73152)
+++ grass/trunk/gui/wxpython/startup/utils.py	2018-08-24 03:05:13 UTC (rev 73153)
@@ -1,7 +1,7 @@
 """
 @package startup.utils
 
- at brief General utilities for GUI startup of GRASS GIS
+ at brief General GUI-independent utilities for GUI startup of GRASS GIS
 
 (C) 2017-2018 by Vaclav Petras the GRASS Development Team
 
@@ -9,6 +9,10 @@
 (>=v2). Read the file COPYING that comes with GRASS for details.
 
 @author Vaclav Petras <wenzeslaus gmail com>
+
+This file should not use (import) anything from GUI code (wx or wxGUI).
+This can potentially be part of the Python library (i.e. it needs to
+solve the errors etc. in a general manner).
 """
 
 



More information about the grass-commit mailing list