[GRASS-dev] [GRASS GIS] #1555: python-scripts in wingrass64svn

GRASS GIS trac at osgeo.org
Sun Jan 29 11:08:59 EST 2012


#1555: python-scripts in wingrass64svn
--------------------------------------+-------------------------------------
 Reporter:  hellik                    |       Owner:  grass-dev@…              
     Type:  defect                    |      Status:  new                      
 Priority:  normal                    |   Milestone:  6.4.2                    
Component:  Python                    |     Version:  6.4.2 RCs                
 Keywords:  wingrass, python scripts  |    Platform:  MSWindows Vista          
      Cpu:  x86-32                    |  
--------------------------------------+-------------------------------------
 how is the best way to start/launch additional python-scipts in
 standalone wingrass642 (not yet tested in osgeo4w-wingrass)

 tested and working examples of python-scipts

 http://grass.osgeo.org/wiki/GRASS_AddOns#r.basin
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.ipso
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.wf

 r.basin.py invokes r.ipso.py and r.wf

 (also needed for test: all r.stream*-addons:
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.stream.angle
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.stream.basins
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.stream.del
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.stream.distance
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.stream.extract
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.stream.order
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.stream.pos
 http://grass.osgeo.org/wiki/GRASS_AddOns#r.stream.stats)

 all case studies with a self compiled wingrass64svn (newly based on
 python272)
 tested on a WinVista32-box without any installed stock python, only the
 wingrass-bundled.

 working example in the nc-sample-dataset (sqlite as vector-db-backend
 needed):

 {{{
 g.region -a rast=elevation at PERMANENT
 r.basin --verbose map=elevation at PERMANENT prefix=a easting=637515
 northing=224615 threshold=50
 }}}


 ----

 '''case study (1)'''

 r.basin.py,r.ipso.py,r.wf.py manually added in C:\Program Files\GRASS
 6.4.2svn\scripts
 r.basin.bat,r.ipso.bat,r.wf.bat manually added in C:\Program Files\GRASS
 6.4.2svn\bin

 the content of the bat-files:

 {{{
 @"%GRASS_PYTHON%" "%GISBASE%/scripts/r.basin.py" %*
 @"%GRASS_PYTHON%" "%GISBASE%/scripts/r.ipso.py" %*
 @"%GRASS_PYTHON%" "%GISBASE%/scripts/r.wf.py" %*
 }}}

 it's needed to change in r.basin.py

 from


 {{{
         grass.message( "##################################" )
         grass.run_command('r.wf.py', map = r_distance,
                                  image = prefix)
         grass.message( "##################################" )

         # Ipsographic curve
         grass.message( "##################################" )
         grass.run_command('r.ipso.py', map = 'r_elevation_crop',
                                    image = prefix,
                                    flags = 'ab')
 }}}


 to


 {{{
  grass.message( "##################################" )
         grass.run_command('r.wf', map = r_distance,
                                  image = prefix)
         grass.message( "##################################" )

         # Ipsographic curve
         grass.message( "##################################" )
         grass.run_command('r.ipso', map = 'r_elevation_crop',
                                    image = prefix,
                                    flags = 'ab')
 }}}




 ''(1)a'' => following command in the wxgui-command-line is working


 {{{
 r.basin --verbose map=elevation at PERMANENT prefix=a easting=637515
 northing=224615 threshold=50
 ABSCHNITT 1a (von 4): Initiiere den Speicher.
 ABSCHNITT 1b (of 4): Ermittle den Fluß aus der Karte heraus.
 [...]
 Bifurcation Ratio (Horton) :   3.5606
 Length Ratio (Horton) :   2.3439
 Area ratio (Horton) :    3.3353
 Slope ratio (Horton):   1.3381
 ##################################
 Done!
 }}}


 ''(1)b'' => only r.basin in the wxgui-command-line, r.basin-wxgui is
 starting, but by starting r.basin from his r.basin-wxgui,
 it's interpreted as

 r.basin.py map=elevation at PERMANENT prefix=b easting=637515 northing=224615
 threshold=50

 and there is following error:

 r.basin.py map=elevation at PERMANENT prefix=b easting=637515 northing=224615
 threshold=50
 C:\Program Files\GRASS 6.4.2svn\extrabin\python.exe: can't
 open file 'r.basin.py': [Errno 2] No such file or directory

 ----

 '''case study (2)'''

 r.basin.py, r.ipso.py, r.wf.py are in i.e. c:\grassscripts

 File -> Launch script: c:\grassscripts\r.basin.py

 => r.basin-wxgui is starting, but by starting r.basin from his r.basin-
 wxgui, again the same error like above:

 r.basin.py map=elevation at PERMANENT prefix=a easting=637515 northing=224615
 threshold=50
 C:\Program Files\GRASS 6.4.2svn\extrabin\python.exe: can't
 open file 'r.basin.py': [Errno 2] No such file or directory


 ----

 '''case study (3)'''

 scripts installed by g.extension

 g.extension.py extension=r.basin svnurl=http://svn.osgeo.org/grass/grass-
 addons/grass6
 Downloading precompiled GRASS Addons <r.basin>...
 Updating metadata file...
 Installation of <r.basin> successfully finished

 g.extension.py extension=r.ipso svnurl=http://svn.osgeo.org/grass/grass-
 addons/grass6
 Downloading precompiled GRASS Addons <r.ipso>...
 Updating metadata file...
 Installation of <r.ipso> successfully finished

 g.extension.py extension=r.wf svnurl=http://svn.osgeo.org/grass/grass-
 addons/grass6
 Downloading precompiled GRASS Addons <r.wf>...
 Updating metadata file...
 Installation of <r.wf> successfully finished

 the addons are installed:


 {{{
 C:\Users\syringia\AppData\Roaming\GRASS6\addons

         bin
         docs
         modules.xml
         r.ipso.py
         r.wf.py
 }}}



 {{{
 C:\Users\syringia\AppData\Roaming\GRASS6\addons\bin

         r.basin.py.bat
         r.ipso.py.bat
         r.wf.py.bat
 }}}


 the content of the bat-files:


 {{{
 @"%GRASS_SH%" "%GISBASE%/scripts/r.basin.py" %*
 @"%GRASS_SH%" "%GISBASE%/scripts/r.ipso.py" %*
 @"%GRASS_SH%" "%GISBASE%/scripts/r.wf.py" %*
 }}}


 ''(3)a'' => r.basin in the wxgui-command-line, a window pops up because
 .py is an ankown extension and
 it's asked how to open

 ''(3)b'' => r.basin.py in the wxgui-command-line, again following error:

 C:\Program Files\GRASS 6.4.2svn\extrabin\python.exe: can't
 open file 'r.basin.py': [Errno 2] No such file or directory


 ----


 any ideas how the situation for python-script in wingrass642 can be
 improved?

 so it seems the corresponding wrapper-bat-files should at least contain
 "%GRASS_PYTHON%" instead of "%GRASS_SH%"

 Helmut

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1555>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list