[GRASS-SVN] r54467 - grass/trunk/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 30 04:57:36 PST 2012


Author: martinl
Date: 2012-12-30 04:57:36 -0800 (Sun, 30 Dec 2012)
New Revision: 54467

Modified:
   grass/trunk/lib/init/grass.py
Log:
grass.py: clean up also location-based tmp dir


Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py	2012-12-29 22:44:05 UTC (rev 54466)
+++ grass/trunk/lib/init/grass.py	2012-12-30 12:57:36 UTC (rev 54467)
@@ -30,6 +30,7 @@
 import subprocess
 import re
 import platform
+import tempfile
 
 # Variables substituted during build process
 if os.environ.has_key('GISBASE'):
@@ -103,12 +104,16 @@
     
 def cleanup():
     tmpdir, lockfile, remove_lockfile
-    # all exits after setting up $tmpdir should also tidy it up
-    cleanup_dir(tmpdir)
-    try_rmdir(tmpdir)
+    # all exits after setting up tmp dirs (system/location) should
+    # also tidy it up
+    for tmpd in [tmpdir, os.path.join(location, ".tmp")]:
+        cleanup_dir(tmpd)
+        try_rmdir(tmpd)
+    
+    # remove lock-file if requested
     if lockfile and remove_lockfile:
         try_remove(lockfile)
-
+    
 def fatal(msg):
     sys.exit(msg)
 
@@ -210,6 +215,8 @@
     if not tmp:
         tmp = os.getenv('TEMP')
     if not tmp:
+        tmp = tempfile.gettempdir()
+    if not tmp:
         tmp = '/tmp'
     tmpdir = os.path.join(tmp, "grass7-%s-%s" % (user, gis_lock))
     try:



More information about the grass-commit mailing list