[GRASS-dev] GRASS addons dependencies

Helmut Kudrnovsky hellik at web.de
Fri Feb 5 00:56:52 PST 2016


Panagiotis Mavrogiorgos wrote
> Hi everybody,
> 
> Some addons depend on other addons. E.g. r.lfp depends on
> r.stream.distance.
> 
> If you try to use it while r.stream.distance is not installed, you get the
> following traceback which is not particularly helpful; especially so if
> you
> are not familiar with Python.
> 
> Traceback (most recent call last):
>>   File "/home/grassuser/.grass7/addons/scripts/r.lfp", line 111, in
>> 
> <module>
>>     sys.exit(main())
>>   File "/home/grassuser/.grass7/addons/scripts/r.lfp", line 43, in main
>>     calculate_lfp(input, output, coords)
>>   File "/home/grassuser/.grass7/addons/scripts/r.lfp", line 67, in
>> calculate_lfp
>>     distance=flds)
>>   File "/usr/lib/grass70/etc/python/grass/script/core.py", line 392, in
>> run_command
>>     ps = start_command(*args, **kwargs)
>>   File "/usr/lib/grass70/etc/python/grass/script/core.py", line 361, in
>> start_command
>>     return Popen(args, **popts)
>>   File "/usr/lib/grass70/etc/python/grass/script/core.py", line 64, in
>> __init__
>>     subprocess.Popen.__init__(self, args, **kwargs)
>>   File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
>>     errread, errwrite)
>>   File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
>>     raise child_exception
>> OSError: [Errno 2] No such file or directory
> 
> 
> So my question is whether there is a way to define addon dependencies, and
> if there is not, what would be a sensible way to support something like
> this.

have a look here:

https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.basin/r.basin.py#L82

82	# check requirements
83	def check_progs():
84	    found_missing = False
85	    for prog in ('r.hypso', 'r.stream.basins', 'r.stream.distance',
'r.stream.extract',
86	    'r.stream.order','r.stream.snap','r.stream.stats', 'r.width.funct'):
87	        if not grass.find_program(prog, '--help'):
88	            found_missing = True
89	            grass.warning(_("'%s' required. Please install '%s' first
using 'g.extension %s'") % (prog, prog, prog))
90	    if found_missing:
91	        grass.fatal(_("An ERROR occurred running r.basin"))



-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/GRASS-addons-dependencies-tp5248966p5249030.html
Sent from the Grass - Dev mailing list archive at Nabble.com.


More information about the grass-dev mailing list