zkwurst / GSoC2017-GRASS-GIS

GNU General Public License v2.0
2 stars 1 forks source link

#%options and #%flag rules #4

Closed zkwurst closed 7 years ago

zkwurst commented 7 years ago

How to write rule that does not allow both flags to get selected:

#%flag
#% key: i
#% label: Return USGS data information without downloading files
#% guisection: USGS Data Selection
#%end

#%flag
#% key: d
#% label: Download available USGS data
#% guisection: USGS Data Selection
#%end
petrasovaa commented 7 years ago

Why do you need the d flag? It should download it by default.

zkwurst commented 7 years ago

Not sure. Just seemed intuitive to require the user to select one or the other? I can see myself always starting to download large amounts of data because I forgot to change it to "i". But you can always just cancel the module. Speaking of, it would probably be good to write a clean-up function for that scenario.

petrasovaa commented 7 years ago

I see why you want this but it's not consistent with how similar modules and flags work in GRASS. We can always change it later.

Clean up would be good, for example for files which were not downloaded fully and for any temporary maps or files. For cleanup you need to put this in there:

atexit.register(cleanup)

and define the cleanup function. The atexit.register ensures the cleanup is called every time. Look for example here how it is used:

https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.skyview/r.skyview.py https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_2/scripts/r.import/r.import.py

zkwurst commented 7 years ago

Very useful. Thank you.