[GRASS-SVN] r34943 - in grass/branches/develbranch_6/gui/wxpython:
gui_modules icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 19 17:19:58 EST 2008
Author: martinl
Date: 2008-12-19 17:19:57 -0500 (Fri, 19 Dec 2008)
New Revision: 34943
Removed:
grass/branches/develbranch_6/gui/wxpython/gui_modules/grassenv.py
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/georect.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
grass/branches/develbranch_6/gui/wxpython/icons/icon.py
Log:
wxGUI: eliminate grassenv, use grass.gisenv() instead
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -50,7 +50,6 @@
import wx.lib.scrolledpanel as scrolled
import sqlbuilder
-import grassenv
import gcmd
import utils
import gdialogs
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -31,13 +31,13 @@
import wx.lib.filebrowsebutton as filebrowse
import wx.lib.mixins.listctrl as listmix
+import grass
+
import gcmd
-import grassenv
import globalvar
import gselect
import menuform
import utils
-import grass
from preferences import globalSettings as UserSettings
class NewVectorDialog(wx.Dialog):
@@ -57,7 +57,7 @@
self.label = wx.StaticText(parent=self.panel, id=wx.ID_ANY,
label=_("Name for new vector map:"))
self.mapName = gselect.Select(parent=self.panel, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE,
- type='vector', mapsets=[grassenv.GetGRASSVariable('MAPSET'),])
+ type='vector', mapsets=[grass.gisenv()['MAPSET'],])
self.mapName.SetFocus()
self.table = wx.CheckBox(parent=self.panel, id=wx.ID_ANY,
@@ -197,7 +197,7 @@
# return fully qualified map name
if '@' not in outmap:
- outmap += '@' + grassenv.GetGRASSVariable('MAPSET')
+ outmap += '@' + grass.gisenv()['MAPSET']
if log:
log.WriteLog(_("New vector map <%s> created") % outmap)
@@ -649,7 +649,7 @@
style=wx.CB_SIMPLE | wx.CB_READONLY,
choices=utils.ListOfMapsets(),
size=(250,-1))
- self.mapset.SetStringSelection(grassenv.GetGRASSVariable("MAPSET"))
+ self.mapset.SetStringSelection(grass.gisenv()['MAPSET'])
bodySizer.Add(item=self.mapset,
pos=(1,1))
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/georect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/georect.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/georect.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -32,6 +32,7 @@
import wx.wizard as wiz
import grass
+
import globalvar
import mapdisp
import render
@@ -75,8 +76,7 @@
#
# get environmental variables
#
- p = gcmd.Command(['g.gisenv', 'get=GISDBASE'])
- self.grassdatabase = p.ReadStdOutput()[0]
+ self.grassdatabase = grass.gisenv()['GISDBASE']
#
# read original environment settings
Deleted: grass/branches/develbranch_6/gui/wxpython/gui_modules/grassenv.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/grassenv.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/grassenv.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -1,44 +0,0 @@
-"""
-MODULE: grassenv
-
-PURPOSE: GRASS environment variable management
-
-AUTHORS: The GRASS Development Team
- Jachym Cepicky (Mendel University of Agriculture)
- Martin Landa <landa.martin gmail.com>
-
-COPYRIGHT: (C) 2006-2007 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.
-
-"""
-
-import os
-import sys
-
-import globalvar
-
-try:
- import subprocess
-except:
- CompatPath = os.path.join(globalvar.ETCWXDIR, "compat")
- sys.path.append(CompatPath)
- import subprocess
-
-# import gcmd
-
-def GetGRASSVariable(var):
- """Return GRASS variable or '' if variable is not defined"""
- # gisEnv = gcmd.Command(['g.gisenv'])
-
- gisEnv = subprocess.Popen(['g.gisenv' + globalvar.EXT_BIN],
- stdin=None,
- stdout=subprocess.PIPE,
- stderr=None)
-
- for item in gisEnv.stdout.readlines():
- if var in item:
- return item.split('=')[1].replace("'",'').replace(';','').strip()
-
- return None
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -27,6 +27,7 @@
import wx.combo
import grass
+
import globalvar
import gcmd
import utils
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -48,12 +48,13 @@
sys.path.append(CompatPath)
from compat import subprocess
+import grass
+
gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
sys.path.append(gmpath)
import render
import toolbars
-import grassenv
import track
import menuform
import gselect
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -23,7 +23,6 @@
import os,sys
import time
-import grassenv
import gcmd
import gselect
import subprocess
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -88,7 +88,8 @@
imagepath = os.path.join(wxbase, "images")
sys.path.append(imagepath)
-import grassenv
+import grass
+
import gselect
import gcmd
import goutput
@@ -1160,7 +1161,7 @@
else:
multiple = False
if p.get('age', '') == 'new':
- mapsets = [grassenv.GetGRASSVariable('MAPSET'),]
+ mapsets = [grass.gisenv()['MAPSET'],]
else:
mapsets = None
@@ -1707,7 +1708,7 @@
if self.grass_task.get_param(key)['element'] in ['cell', 'vector']:
# mapname -> mapname at mapset
if '@' not in value:
- value = value + '@' + grassenv.GetGRASSVariable('MAPSET')
+ value = value + '@' + grass.gisenv()['MAPSET']
self.grass_task.set_param(key, value)
cmd_validated.append(key + '=' + value)
i = i + 1
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -32,8 +32,8 @@
import wx.lib.mixins.listctrl as listmix
from wx.lib.wordwrap import wordwrap
+import grass
import gcmd
-import grassenv
import utils
import globalvar
from debug import Debug as Debug
@@ -542,9 +542,10 @@
# -> mapser
# -> location
# -> gisdbase
- gisdbase = grassenv.GetGRASSVariable("GISDBASE")
- location_name = grassenv.GetGRASSVariable("LOCATION_NAME")
- mapset_name = grassenv.GetGRASSVariable("MAPSET")
+ gisenv = grass.gisenv()
+ gisdbase = gisenv['GISDBASE']
+ location_name = gisenv['LOCATION_NAME']
+ mapset_name = gisenv['MAPSET']
mapset_file = os.path.join(gisdbase, location_name, mapset_name, self.fileName)
location_file = os.path.join(gisdbase, location_name, self.fileName)
@@ -612,9 +613,11 @@
loc = self.Get(group='advanced', key='settingsFile', subkey='type')
home = os.path.expanduser("~") # MS Windows fix ?
- gisdbase = grassenv.GetGRASSVariable("GISDBASE")
- location_name = grassenv.GetGRASSVariable("LOCATION_NAME")
- mapset_name = grassenv.GetGRASSVariable("MAPSET")
+
+ gisenv = grass.gisenv()
+ gisdbase = gisenv['GISDBASE']
+ location_name = gisenv['LOCATION_NAME']
+ mapset_name = gisenv['MAPSET']
filePath = None
if loc == 'home':
filePath = os.path.join(home, self.fileName)
@@ -1700,7 +1703,7 @@
self.all_mapsets = utils.ListOfMapsets(all=True)
self.accessible_mapsets = utils.ListOfMapsets(all=False)
- self.curr_mapset = grassenv.GetGRASSVariable('MAPSET')
+ self.curr_mapset = grass.gisenv()['MAPSET']
# make a checklistbox from available mapsets and check those that are active
sizer = wx.BoxSizer(wx.VERTICAL)
@@ -1776,8 +1779,8 @@
self.InsertColumn(0, _('Mapset'))
self.InsertColumn(1, _('Owner'))
self.InsertColumn(2, _('Group'))
- locationPath = os.path.join(grassenv.GetGRASSVariable('GISDBASE'),
- grassenv.GetGRASSVariable('LOCATION_NAME'))
+ gisenv = grass.gisenv()
+ locationPath = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'])
for mapset in mapsets:
index = self.InsertStringItem(sys.maxint, mapset)
mapsetPath = os.path.join(locationPath,
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -37,6 +37,8 @@
import wx
from wx.lib.newevent import NewEvent
+import grass
+
import globalvar
import utils
import gcmd
@@ -434,15 +436,8 @@
if self.gisrc:
os.environ["GISRC"] = self.gisrc
- gisenvCmd = gcmd.Command(["g.gisenv"])
-
- for line in gisenvCmd.ReadStdOutput():
- line = line.strip()
- key, val = line.split("=")
- val = val.replace(";","")
- val = val.replace("'","")
- self.env[key] = val
-
+ self.env = grass.gisenv()
+
# back to original gisrc
if self.gisrc:
os.environ["GISRC"] = gisrc_orig
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -24,7 +24,8 @@
import os,sys
import time
-import grassenv
+import grass
+
import gcmd
import globalvar
@@ -48,7 +49,7 @@
#
self.vectmap = vectmap
if not "@" in self.vectmap:
- self.vectmap = self.vectmap + "@" + grassenv.GetGRASSVariable ("MAPSET")
+ self.vectmap = self.vectmap + "@" + grass.gisenv()['MAPSET']
self.mapname, self.mapset = self.vectmap.split("@")
self.layer,self.tablename, self.column, self.database, self.driver =\
os.popen("v.db.connect -g map=%s" %\
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -24,9 +24,10 @@
import wx
import os, sys
+import grass
+
import globalvar
import gcmd
-import grassenv
import gdialogs
import vdigit
from vdigit import VDigitSettingsDialog as VDigitSettingsDialog
@@ -1176,7 +1177,7 @@
# select vector map layer in the current mapset
layerNameList = []
self.layers = self.mapcontent.GetListOfLayers(l_type="vector",
- l_mapset=grassenv.GetGRASSVariable('MAPSET'))
+ l_mapset=grass.gisenv()['MAPSET'])
for layer in self.layers:
if not layer.name in layerNameList: # do not duplicate layer
layerNameList.append (layer.GetName())
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -23,7 +23,6 @@
import grass
import gcmd
-import grassenv
try:
import subprocess
except:
@@ -118,9 +117,9 @@
if result:
mapname = result['fullname']
else:
- mapname += '@' + grassenv.GetGRASSVariable('MAPSET')
+ mapname += '@' + grass.gisenv()['MAPSET']
else:
- mapname += '@' + grassenv.GetGRASSVariable('MAPSET')
+ mapname += '@' + grass.gisenv()['MAPSET']
dcmd[idx] = dcmd[idx].split('=')[0] + '=' + mapname
return mapname
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -30,13 +30,14 @@
import wx.lib.newevent
import wx.lib.buttons as buttons
+import grass
+
import gdialogs
import globalvar
import menuform
import mapdisp
import render
import gcmd
-import grassenv
import histogram
import utils
import profile
@@ -108,7 +109,7 @@
# title
self.mapdisplay.SetTitle(_("GRASS GIS Map Display: " +
str(self.disp_idx + 1) +
- " - Location: " + grassenv.GetGRASSVariable("LOCATION_NAME")))
+ " - Location: " + grass.gisenv()["LOCATION_NAME"]))
# show new display
if kargs['showMapDisplay'] is True:
@@ -302,7 +303,7 @@
internal=True) == layer.GetName():
self.popupMenu.Check(self.popupID14, True)
- if layer.GetMapset() != grassenv.GetGRASSVariable("MAPSET"):
+ if layer.GetMapset() != grass.gisenv()['MAPSET']:
# only vector map in current mapset can be edited
self.popupMenu.Enable (self.popupID5, False)
self.popupMenu.Enable (self.popupID6, False)
Modified: grass/branches/develbranch_6/gui/wxpython/icons/icon.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2008-12-19 21:39:40 UTC (rev 34942)
+++ grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2008-12-19 22:19:57 UTC (rev 34943)
@@ -26,13 +26,9 @@
gmPath = os.path.join(os.getenv("GISBASE"), "etc", "wxpython", "gui_modules")
sys.path.append(gmPath)
-import grassenv
import globalvar
from preferences import globalSettings as UserSettings
-# iconpath = grassenv.GetGRASSVariable('GRASS_ICONPATH')
-# if not iconpath:
-# iconpath = os.getenv("GRASS_ICONPATH")
iconTheme = UserSettings.Get(group='advanced', key='iconTheme', subkey='type')
if iconTheme and iconTheme == 'silk':
iconpath = os.path.join(globalvar.ETCDIR, "gui", "icons", "silk")
More information about the grass-commit
mailing list