[GRASS-SVN] r43454 -
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Sep 13 17:18:08 EDT 2010
Author: martinl
Date: 2010-09-13 21:18:08 +0000 (Mon, 13 Sep 2010)
New Revision: 43454
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/preferences.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
Log:
fix ListOfMapsets (sync with develbr6)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py 2010-09-13 18:10:07 UTC (rev 43453)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py 2010-09-13 21:18:08 UTC (rev 43454)
@@ -680,7 +680,7 @@
self.mapset = wx.ComboBox(parent=self, id=wx.ID_ANY,
style=wx.CB_SIMPLE | wx.CB_READONLY,
- choices=utils.ListOfMapsets(),
+ choices=utils.ListOfMapsets(get = 'accessible'),
size=(250,-1))
self.mapset.SetStringSelection(grassenv.GetGRASSVariable("MAPSET"))
bodySizer.Add(item=self.mapset,
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py 2010-09-13 18:10:07 UTC (rev 43453)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py 2010-09-13 21:18:08 UTC (rev 43454)
@@ -191,7 +191,7 @@
# list of mapsets in current location
if mapsets is None:
- mapsets = utils.ListOfMapsets()
+ mapsets = utils.ListOfMapsets(get = 'accessible')
# map element types to g.mlist types
elementdict = {'cell':'rast',
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/preferences.py 2010-09-13 18:10:07 UTC (rev 43453)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/preferences.py 2010-09-13 21:18:08 UTC (rev 43454)
@@ -1722,8 +1722,8 @@
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
- self.all_mapsets_ordered = utils.ListOfMapsets(ordered=True)
- self.accessible_mapsets = utils.ListOfMapsets(accessible=True)
+ self.all_mapsets_ordered = utils.ListOfMapsets(get = 'ordered')
+ self.accessible_mapsets = utils.ListOfMapsets(get = 'accessible')
self.curr_mapset = grassenv.GetGRASSVariable('MAPSET')
# make a checklistbox from available mapsets and check those that are active
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py 2010-09-13 18:10:07 UTC (rev 43453)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py 2010-09-13 21:18:08 UTC (rev 43454)
@@ -204,87 +204,46 @@
return catstr.strip(',')
-def ListOfMapsets(all=False, accessible=False, ordered=False):
- """Get list of available/accessible mapsets
+def ListOfMapsets(get = 'ordered'):
+ """!Get list of available/accessible mapsets
- @param all if True get list of all mapsets
-
+ @param get method ('all', 'accessible', 'ordered')
+
@return list of mapsets
+ @return None on error
"""
mapsets = []
-
- ### FIXME
- # problem using Command here (see preferences.py)
- # cmd = gcmd.Command(['g.mapsets', '-l'])
- if all:
- cmd = subprocess.Popen(['g.mapsets' + globalvar.EXT_BIN, '-l'],
- stdout=subprocess.PIPE)
- try:
- # for mset in cmd.ReadStdOutput()[0].split(' '):
- for line in cmd.stdout.readlines():
- for mset in line.strip('%s' % os.linesep).split(' '):
- if len(mset) == 0:
- continue
- mapsets.append(mset)
- except:
- raise gcmd.CmdError(_('Unable to get list of available mapsets.'))
-
- elif accessible:
+ if get == 'all' or get == 'ordered':
ret = gcmd.RunCommand('g.mapsets',
read = True,
- flags = 'p',
- fs = ';')
- if ret:
- mapsets = ret.rstrip('\n').split(';')
- else:
- raise gcmd.CmdError(cmd = 'g.mapsets',
- message = _('Unable to get list of accessible mapsets.'))
-
- elif ordered:
- ret = gcmd.RunCommand('g.mapsets',
- read = True,
+ quiet = True,
flags = 'l',
fs = ';')
+
if ret:
- mapsets_available = ret.rstrip('\n').split(';')
+ mapsets = ret.replace('\n', '').strip().split(';')
+ ListSortLower(mapsets)
else:
- raise gcmd.CmdError(cmd = 'g.mapsets',
- message = _('Unable to get list of available mapsets.'))
-
+ return None
+
+ if get == 'accessible' or get == 'ordered':
ret = gcmd.RunCommand('g.mapsets',
read = True,
+ quiet = True,
flags = 'p',
fs = ';')
if ret:
- mapsets_accessible = ret.rstrip('\n').split(';')
+ if get == 'accessible':
+ mapsets = ret.replace('\n', '').strip().split(';')
+ else:
+ mapsets_accessible = ret.replace('\n', '').strip().split(';')
+ for mapset in mapsets_accessible:
+ mapsets.remove(mapset)
+ mapsets = mapsets_accessible + mapsets
else:
- raise gcmd.CmdError(cmd = 'g.mapsets',
- message = _('Unable to get list of accessible mapsets.'))
-
- for mapset in mapsets_accessible:
- mapsets_available.remove(mapset)
- mapsets = mapsets_accessible + mapsets_available
-
+ return None
- else:
- # cmd = gcmd.Command(['g.mapsets', '-p'])
- cmd = subprocess.Popen(['g.mapsets' + globalvar.EXT_BIN, '-p'],
- stdout=subprocess.PIPE)
- try:
- # for mset in cmd.ReadStdOutput()[0].split(' '):
- for line in cmd.stdout.readlines():
- for mset in line.strip('%s' % os.linesep).split(' '):
- if len(mset) == 0:
- continue
- mapsets.append(mset)
- except:
- raise gcmd.CmdError(_('Unable to get list of accessible mapsets.'))
-
- # This one sorts mapset names, thus prevents the user from modifying their
- # order in the SEARH_PATH from GUI, unlike the `ordered' above.
- ListSortLower(mapsets)
-
return mapsets
def ListSortLower(list):
More information about the grass-commit
mailing list