[GRASSGUI] commands from menus and database table not working

Michael Barton michael.barton at asu.edu
Mon May 21 11:10:10 EDT 2007


Jachym,

Yet another casualty of the switch from command strings to command lists.
Glynn made a change here that will be better for all in the end. He tried to
catch instances of commands as strings and convert them to lists, but didn't
get them all (there were a lot of places). But we've almost got it done.
Specific comments below.


On 5/21/07 3:14 AM, "Jachym Cepicky" <jachym.cepicky at gmail.com> wrote:

> hi,
> 
> after some weeks, I'm back from the middle of nowhere and I tried some
> new features of your wx gui.
> 
> It looks good, however, no commands are working now:
> 
> 1 - start the gui
> wxgrass &
> 2 - Select Raster-> Reports and statistics -> Report basic file
> information
> 
> 3 - Fill the form
> 
> 4 - Hint "Run" button:
> 
> Result:
> 
> Traceback (most recent call last):
>   File "/usr/src/gis/grass/addons/gui/gui_modules/menuform.py", line
> 619, in OnRun
>     self.goutput.runCmd(cmd)
>   File "/usr/src/gis/grass/addons/gui/gui_modules/wxgui_utils.py", line
> 922, in runCmd
>     self.cmd_output.write("$ " + command + "\n")
> TypeError: cannot concatenate 'str' and 'list' objects
> 
> Why:

The problem is not command but "$ " and "\n". They is a strings. Change to

['$ '] + command + ['\n']


> 
> method getCmd() of grassTask() class (gui_modules/menform.py, line 215)
> returns not command string (e.g. "r.info elevation.dem"), but already
> command list (e.g. ["r.info", "map=elevation.dem"]).
> 
> This is in conflict with rest of the code, where ever cmd.split(" ") is
> called (e.g. wxgui.py line 410 or gui_modules/wxgui_utils.py, line 868).

cmd.split(" ") is potentially problematic and we should avoid it. For
example, <some command> map="My map" will end up as

['<command>', 'map=My', 'map'].

Or <command> query="attribute1>5 and attribute2<15"

['<command>', 'query=attribute>5', 'and', 'attribute2<15']

> 
> So, what to do? Fix getCmd(), so it returns string or go through whole
> code and try to fix all cmd.split() calls?

The latter. We've already got most of them, but there are a few left
apparently.

Michael

> 
> Jachym  

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton





More information about the grass-gui mailing list