[GRASS-SVN] r64406 - in grass/trunk/gui/wxpython: animation core gmodeler mapdisp modules psmap vnet web_services
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Feb 2 10:30:09 PST 2015
Author: martinl
Date: 2015-02-02 10:30:09 -0800 (Mon, 02 Feb 2015)
New Revision: 64406
Modified:
grass/trunk/gui/wxpython/animation/nviztask.py
grass/trunk/gui/wxpython/animation/provider.py
grass/trunk/gui/wxpython/core/render.py
grass/trunk/gui/wxpython/core/utils.py
grass/trunk/gui/wxpython/core/ws.py
grass/trunk/gui/wxpython/gmodeler/model.py
grass/trunk/gui/wxpython/mapdisp/main.py
grass/trunk/gui/wxpython/modules/colorrules.py
grass/trunk/gui/wxpython/psmap/instructions.py
grass/trunk/gui/wxpython/vnet/vnet_core.py
grass/trunk/gui/wxpython/vnet/vnet_data.py
grass/trunk/gui/wxpython/web_services/dialogs.py
Log:
wxGUI: replace utils cmd list <-> tuple by grass.script.gtask functions
Modified: grass/trunk/gui/wxpython/animation/nviztask.py
===================================================================
--- grass/trunk/gui/wxpython/animation/nviztask.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/animation/nviztask.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -22,7 +22,7 @@
from core.workspace import ProcessWorkspaceFile
from core.gcmd import RunCommand, GException
-from core.utils import GetLayerNameFromCmd, CmdToTuple, _
+from core.utils import GetLayerNameFromCmd, _
from grass.script import task as gtask
from core.settings import UserSettings
@@ -284,7 +284,7 @@
self.task.set_flag('overwrite', True)
self.task.set_param('output', 'tobechanged')
cmd = self.task.get_cmd(ignoreErrors=False, ignoreRequired=False, ignoreDefault=True)
- return CmdToTuple(cmd)
+ return gtask.cmdlist_to_tuple(cmd)
def GetRegion(self):
return self.region
Modified: grass/trunk/gui/wxpython/animation/provider.py
===================================================================
--- grass/trunk/gui/wxpython/animation/provider.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/animation/provider.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -29,11 +29,12 @@
from core.gcmd import RunCommand, GException
from core.settings import UserSettings
from core.debug import Debug
-from core.utils import _, CmdToTuple, autoCropImageFromFile
+from core.utils import _, autoCropImageFromFile
from animation.utils import HashCmd, HashCmds, GetFileFromCmd, GetFileFromCmds
import grass.script.core as gcore
+from grass.script.task import cmdlist_to_tuple
from grass.pydispatch.signal import Signal
@@ -269,7 +270,7 @@
transparent=True, bgcolor=(0, 0, 0))
Debug.msg(1, "Render raster legend " + str(filename))
- cmdTuple = CmdToTuple(cmd)
+ cmdTuple = cmdlist_to_tuple(cmd)
returncode, stdout, messages = read2_command(cmdTuple[0], **cmdTuple[1])
if returncode == 0:
@@ -490,7 +491,7 @@
transparent=transparency, bgcolor=bgcolor)
if region:
os.environ['GRASS_REGION'] = gcore.region_env(**region)
- cmdTuple = CmdToTuple(cmd)
+ cmdTuple = cmdlist_to_tuple(cmd)
returncode, stdout, messages = read2_command(cmdTuple[0], **cmdTuple[1])
if returncode != 0:
gcore.warning("Rendering failed:\n" + messages)
@@ -523,7 +524,7 @@
os.environ['GRASS_REGION'] = gcore.region_env(region3d=True, **region)
Debug.msg(1, "Render image to file " + str(filename))
- cmdTuple = CmdToTuple(cmd)
+ cmdTuple = cmdlist_to_tuple(cmd)
cmdTuple[1]['output'] = os.path.splitext(filename)[0]
# set size
cmdTuple[1]['size'] = '%d,%d' % (imageWidth, imageHeight)
Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/core/render.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -39,6 +39,7 @@
from grass.script import core as grass
from grass.script.utils import try_remove
+from grass.script.task import cmdlist_to_tuple
from grass.pydispatch.signal import Signal
from core import utils
@@ -104,9 +105,9 @@
if self.type == 'command':
self.cmd = list()
for c in cmd:
- self.cmd.append(utils.CmdToTuple(c))
+ self.cmd.append(cmdlist_to_tuple(c))
else:
- self.cmd = utils.CmdToTuple(cmd)
+ self.cmd = cmdlist_to_tuple(cmd)
self.active = active
self.hidden = hidden
@@ -302,9 +303,9 @@
if self.type == 'command':
self.cmd = []
for c in cmd:
- self.cmd.append(utils.CmdToTuple(c))
+ self.cmd.append(cmdlist_to_tuple(c))
else:
- self.cmd = utils.CmdToTuple(cmd)
+ self.cmd = cmdlist_to_tuple(cmd)
Debug.msg(3, "Layer.SetCmd(): cmd='%s'" % self.GetCmd(string = True))
# for re-rendering
Modified: grass/trunk/gui/wxpython/core/utils.py
===================================================================
--- grass/trunk/gui/wxpython/core/utils.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/core/utils.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -480,59 +480,8 @@
:return: command string
"""
- return ' '.join(CmdTupleToList(cmd))
+ return ' '.join(gtask.cmdtuple_to_list(cmd))
-def CmdTupleToList(cmd):
- """Convert command tuple to list.
-
- :param cmd: GRASS command given as tuple
-
- :return: command in list
- """
- cmdList = []
- if not cmd:
- return cmdList
-
- cmdList.append(cmd[0])
-
- if 'flags' in cmd[1]:
- for flag in cmd[1]['flags']:
- cmdList.append('-' + flag)
- for flag in ('help', 'verbose', 'quiet', 'overwrite'):
- if flag in cmd[1] and cmd[1][flag] is True:
- cmdList.append('--' + flag)
-
- for k, v in cmd[1].iteritems():
- if k in ('flags', 'help', 'verbose', 'quiet', 'overwrite'):
- continue
- cmdList.append('%s=%s' % (k, v))
-
- return cmdList
-
-def CmdToTuple(cmd):
- """Convert command list to tuple for gcmd.RunCommand()"""
- if len(cmd) < 1:
- return None
-
- dcmd = {}
- for item in cmd[1:]:
- if '=' in item: # params
- key, value = item.split('=', 1)
- dcmd[str(key)] = str(value).replace('"', '')
- elif item[:2] == '--': # long flags
- flag = item[2:]
- if flag in ('help', 'verbose', 'quiet', 'overwrite'):
- dcmd[str(flag)] = True
- elif len(item) == 2 and item[0] == '-': # -> flags
- if 'flags' not in dcmd:
- dcmd['flags'] = ''
- dcmd['flags'] += item[1]
- else: # unnamed parameter
- module = gtask.parse_interface(cmd[0])
- dcmd[module.define_first()] = item
-
- return (cmd[0], dcmd)
-
def PathJoin(*args):
"""Check path created by os.path.join"""
path = os.path.join(*args)
Modified: grass/trunk/gui/wxpython/core/ws.py
===================================================================
--- grass/trunk/gui/wxpython/core/ws.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/core/ws.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -23,6 +23,7 @@
from wx.lib.newevent import NewEvent
from grass.script.utils import try_remove
+from grass.script.task import cmdtuple_to_list
from grass.script import core as grass
from core import utils
@@ -126,7 +127,7 @@
self.downloading = True
self.fetching_cmd = cmd
- cmdList = utils.CmdTupleToList(cmd)
+ cmdList = cmdtuple_to_list(cmd)
if Debug.GetLevel() < 3:
cmdList.append('--quiet')
Modified: grass/trunk/gui/wxpython/gmodeler/model.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/model.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/gmodeler/model.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -670,7 +670,7 @@
vlist = list()
if condText[0] == '`' and condText[-1] == '`':
# run command
- cmd, dcmd = utils.CmdToTuple(condText[1:-1].split(' '))
+ cmd, dcmd = gtask.cmdlist_to_tuple(condText[1:-1].split(' '))
ret = RunCommand(cmd,
read = True,
**dcmd)
Modified: grass/trunk/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/main.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/mapdisp/main.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -44,6 +44,7 @@
from grass.script.utils import try_remove
from grass.script import core as grass
+from grass.script.task import cmdtuple_to_list
from grass.pydispatch.signal import Signal
# for standalone app
@@ -248,7 +249,7 @@
def __getattr__(self, name):
if name == 'cmd':
- return utils.CmdTupleToList(self._maplayer.GetCmd())
+ return cmdtuple_to_list(self._maplayer.GetCmd())
elif hasattr(self._maplayer, name):
return getattr(self._maplayer, name)
elif name == 'maplayer':
Modified: grass/trunk/gui/wxpython/modules/colorrules.py
===================================================================
--- grass/trunk/gui/wxpython/modules/colorrules.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/modules/colorrules.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -33,6 +33,7 @@
import wx.lib.filebrowsebutton as filebrowse
import grass.script as grass
+from grass.script.task import cmdlist_to_tuple
from core import globalvar
from core import utils
@@ -692,7 +693,7 @@
if self.properties['sourceColumn'] and self.properties['sourceColumn'] != 'cat':
cmd.append('column=%s' % self.properties['sourceColumn'])
- cmd = utils.CmdToTuple(cmd)
+ cmd = cmdlist_to_tuple(cmd)
if self.inmap:
ctable = RunCommand(cmd[0], **cmd[1])
@@ -739,7 +740,7 @@
if self.mapType == 'vector' and self.properties['sourceColumn'] \
and self.properties['sourceColumn'] != 'cat':
cmd.append('column=%s' % self.properties['sourceColumn'])
- cmd = utils.CmdToTuple(cmd)
+ cmd = cmdlist_to_tuple(cmd)
ret = RunCommand(cmd[0], **cmd[1])
if ret != 0:
return False
@@ -1371,7 +1372,7 @@
def CreateAttrTable(self, dcmd, layer, params, propwin):
"""Create attribute table"""
if dcmd:
- cmd = utils.CmdToTuple(dcmd)
+ cmd = cmdlist_to_tuple(dcmd)
ret = RunCommand(cmd[0], **cmd[1])
if ret == 0:
self.OnSelectionInput(None)
Modified: grass/trunk/gui/wxpython/psmap/instructions.py
===================================================================
--- grass/trunk/gui/wxpython/psmap/instructions.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/psmap/instructions.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -39,9 +39,10 @@
import wx
import grass.script as grass
+from grass.script.task import cmdlist_to_tuple
from core.gcmd import RunCommand, GError, GMessage, GWarning
-from core.utils import CmdToTuple, GetCmdString, _
+from core.utils import GetCmdString, _
from dbmgr.vinfo import VectorDBInfo
from psmap.utils import *
@@ -439,7 +440,7 @@
map = MapFrame(wx.NewId())
self.AddInstruction(map)
if regionInstruction:
- cmd = CmdToTuple(regionInstruction.strip('# ').split())
+ cmd = cmdlist_to_tuple(regionInstruction.strip('# ').split())
# define scaleType
if len(cmd[1]) <= 3:
Modified: grass/trunk/gui/wxpython/vnet/vnet_core.py
===================================================================
--- grass/trunk/gui/wxpython/vnet/vnet_core.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/vnet/vnet_core.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -22,6 +22,7 @@
import os
from grass.script.utils import try_remove
from grass.script import core as grass
+from grass.script.task import cmdlist_to_tuple
import wx
@@ -361,7 +362,7 @@
cmd=cmd,
checked=True)
if cmd_colors:
- layerStyleVnetColors = utils.CmdToTuple(cmd_colors)
+ layerStyleVnetColors = cmdlist_to_tuple(cmd_colors)
RunCommand(layerStyleVnetColors[0],
**layerStyleVnetColors[1])
Modified: grass/trunk/gui/wxpython/vnet/vnet_data.py
===================================================================
--- grass/trunk/gui/wxpython/vnet/vnet_data.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/vnet/vnet_data.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -28,6 +28,7 @@
from grass.script.utils import try_remove
from grass.script import core as grass
+from grass.script.task import cmdlist_to_tuple
import wx
@@ -992,7 +993,7 @@
if colorsCmd:
colorsCmd.append('map=%s' % self.fullName)
- layerStyleVnetColors = utils.CmdToTuple(colorsCmd)
+ layerStyleVnetColors = cmdlist_to_tuple(colorsCmd)
RunCommand(layerStyleVnetColors[0],
**layerStyleVnetColors[1])
Modified: grass/trunk/gui/wxpython/web_services/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/web_services/dialogs.py 2015-02-02 18:25:03 UTC (rev 64405)
+++ grass/trunk/gui/wxpython/web_services/dialogs.py 2015-02-02 18:30:09 UTC (rev 64406)
@@ -27,11 +27,12 @@
from copy import deepcopy
import grass.script as grass
+from grass.script.task import cmdlist_to_tuple, cmdtuple_to_list
from core import globalvar
from core.debug import Debug
from core.gcmd import GMessage, GWarning, GError, RunCommand
-from core.utils import GetSettingsPath, CmdToTuple, CmdTupleToList, _
+from core.utils import GetSettingsPath, _
from core.gconsole import CmdThread, GStderr, EVT_CMD_DONE, EVT_CMD_OUTPUT
from gui_core.gselect import Select
@@ -549,7 +550,7 @@
ws_cap_files = self._getCapFiles()
# create properties dialog
cmd_list = ltree.GetLayerInfo(layer,'cmd')
- cmd = CmdToTuple(cmd_list)
+ cmd = cmdlist_to_tuple(cmd_list)
prop_win = WSPropertiesDialog(parent = self.parent,
giface = self.giface,
@@ -705,7 +706,7 @@
propwin = self)
#TODO use just list or tuple
- cmd = CmdToTuple(lcmd)
+ cmd = cmdlist_to_tuple(lcmd)
self.revert_cmd = cmd
self._setRevertCapFiles(self._getCapFiles())
@@ -992,7 +993,7 @@
region = self._giface.GetMapWindow().GetMap().SetRegion()
env['GRASS_REGION'] = region
- cmdList = CmdTupleToList(cmd)
+ cmdList = cmdtuple_to_list(cmd)
self.currentPid = self.thread.GetId()
self.thread.RunCmd(cmdList, env=env, stderr=self.cmdStdErr)
More information about the grass-commit
mailing list