Преглед изворни кода

grass.py: clean up also location-based tmp dir

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54467 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa пре 12 година
родитељ
комит
82ccade4e0
1 измењених фајлова са 11 додато и 4 уклоњено
  1. 11 4
      lib/init/grass.py

+ 11 - 4
lib/init/grass.py

@@ -30,6 +30,7 @@ import string
 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_dir(path):
     
 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 @@ def create_tmp():
     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: