[GRASS-dev] [GRASS GIS] #1574: v.to.rast in python loop: Error raster already exists

#1574: v.to.rast in python loop: Error raster already exists
-----------------------+----------------------------------------------------
Reporter: jradinger | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: wxGUI | Version: svn-develbranch6
Keywords: | Platform: MacOSX
      Cpu: OSX/Intel |
-----------------------+----------------------------------------------------
When I try to launch a python script via File -> lauch Script
that calls v.to.rast in loop, I get the error that the raster file already
exists.
This is although no such raster exists before running the script (deleted
before with g.remove and cross checked with g.list)

I attached a sample script for the North Carolina dataset also including
g.list command and time.sleep()...
This was also reproduced by Moritz Lennert. His comment on this:

"This is a bit over my head as I don't have a good view of how the GUI
works (CC to Martin), but AFAICT the script is run through RunCmd on
line 599 in gui/wxpython/gui_core/goutput.py [1].
So it quite definitely seems a wxgui problem, but I don't know how to go
further with this...
[1]
http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py#L599
___"

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1574&gt;
GRASS GIS <http://grass.osgeo.org>

#1574: WXGUI Launch script: "output already exists"
---------------------------+------------------------------------------------
Reporter: jradinger | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: wxGUI | Version: svn-develbranch6
Keywords: wxgui, script | Platform: All
      Cpu: All |
---------------------------+------------------------------------------------
Changes (by mlennert):

  * keywords: => wxgui, script
  * platform: MacOSX => All
  * cpu: OSX/Intel => All

Comment:

Replying to [ticket:1574 jradinger]:
> When I try to launch a python script via File -> lauch Script
> that calls v.to.rast in loop, I get the error that the raster file
already exists.

After a bit of testing I can confirm the error, but it seems that this is
neither linked to a for loop, nor to the fact that this is a python
script. I tried both python and bash scripts with simple operations such
as v.to.rast, r.to.vect and v.select and they all failed with the message
that the output exists, although I always run

{{{
g.mremove rast="*" vect="*" -f
}}}

before running the script.

I've tried with very simple scripts not invoking the parser (i.e. just
one-line bash scripts) and get the same message.

So, it seems that the GUI tries to run the GRASS commands within the
script twice. The first time it works as foreseen, the second time it
logically bails out with the message that the output already exists. The
rest of the script is only run once (at least any print or echo statements
only show up once).

On the command line all these script work perfectly. Calling the script
directly from the GUI command prompt also leads to the same error message.

This happens to every GRASS command in the script, i.e.:

{{{
#! /bin/bash

echo "running script"
r.to.vect input=myroads output=myroads
v.select ainput=roadsmajor binput=censusblk_swwake output=selected_roads
operator=within
}}}

gives me two error messages about myroads and selected_roads already
existing, but both commands ran fine and I have the expected results.

Moritz

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1574#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1574: WXGUI Launch script: "output already exists"
---------------------------+------------------------------------------------
Reporter: jradinger | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: wxGUI | Version: svn-trunk
Keywords: wxgui, script | Platform: All
      Cpu: All |
---------------------------+------------------------------------------------
Changes (by mlennert):

  * version: svn-develbranch6 => svn-trunk

Comment:

Just checked and this is present in trunk, 6.5 and 6.4 release branch.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1574#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1574: WXGUI Launch script: "output already exists"
-----------------------------------+----------------------------------------
Reporter: jradinger | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: wxgui, script, python | Platform: MSWindows Vista
      Cpu: All |
-----------------------------------+----------------------------------------
Changes (by adamGIS89):

  * keywords: wxgui, script => wxgui, script, python
  * platform: All => MSWindows Vista
  * milestone: 6.5.0 => 7.0.0

Comment:

This seems to exist in grass 7.0 beta as well.
I ran a python script this morning and it told me that most of my output
files already existed. The code still delivered mostly right results.

An example:
r.to.vect complete.
ERROR: option <output>: <xKM_585_590RNV> exists.
Extracting areas...

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1574#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1574: WXGUI Launch script: "output already exists"
-----------------------------------+----------------------------------------
Reporter: jradinger | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: wxgui, script, python | Platform: MSWindows Vista
      Cpu: All |
-----------------------------------+----------------------------------------

Comment(by annakrat):

Replying to [comment:3 adamGIS89]:
> This seems to exist in grass 7.0 beta as well.
> I ran a python script this morning and it told me that most of my output
files already existed. The code still delivered mostly right results.
>
> An example:
> r.to.vect complete.
> ERROR: option <output>: <xKM_585_590RNV> exists.
> Extracting areas...

Tested trunk with Windows 8 and Ubuntu, I don't have any problems like
that. It seems to run only once.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1574#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>