[GRASS-SVN] r41817 - grass/trunk/scripts/r.fillnulls
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Apr 12 02:55:24 EDT 2010
Author: glynn
Date: 2010-04-12 02:55:07 -0400 (Mon, 12 Apr 2010)
New Revision: 41817
Modified:
grass/trunk/scripts/r.fillnulls/r.fillnulls.py
Log:
Fix bug with uninitialised variables and exit handler
Modified: grass/trunk/scripts/r.fillnulls/r.fillnulls.py
===================================================================
--- grass/trunk/scripts/r.fillnulls/r.fillnulls.py 2010-04-11 21:11:54 UTC (rev 41816)
+++ grass/trunk/scripts/r.fillnulls/r.fillnulls.py 2010-04-12 06:55:07 UTC (rev 41817)
@@ -60,15 +60,23 @@
import atexit
import grass.script as grass
+vecttmp = None
+tmp1 = None
+usermask = None
+mapset = None
+
# what to do in case of user break:
def cleanup():
#delete internal mask and any TMP files:
- rasts = [tmp1 + ext for ext in ['', '.buf', '_filled']]
- grass.run_command('g.remove', flags = 'f', rast = rasts)
- grass.run_command('g.remove', flags = 'f', vect = vecttmp)
+ if tmp1:
+ rasts = [tmp1 + ext for ext in ['', '.buf', '_filled']]
+ grass.run_command('g.remove', flags = 'f', rast = rasts)
+ if vecttmp:
+ grass.run_command('g.remove', flags = 'f', vect = vecttmp)
grass.run_command('g.remove', rast = 'MASK')
- if grass.find_file(usermask, mapset = mapset)['file']:
- grass.run_command('g.rename', rast = (usermask, 'MASK'))
+ if usermask and mapset:
+ if grass.find_file(usermask, mapset = mapset)['file']:
+ grass.run_command('g.rename', rast = (usermask, 'MASK'))
def main():
global vecttmp, tmp1, usermask, mapset
@@ -78,13 +86,13 @@
tension = options['tension']
smooth = options['smooth']
+ mapset = grass.gisenv()['MAPSET']
+ unique = str(os.getpid())
+
#check if input file exists
if not grass.find_file(input)['file']:
grass.fatal(_("<%s> does not exist.") % input)
- mapset = grass.gisenv()['MAPSET']
- unique = str(os.getpid())
-
# check if a MASK is already present:
usermask = "usermask_mask." + unique
if grass.find_file('MASK', mapset = mapset)['file']:
More information about the grass-commit
mailing list