summaryrefslogtreecommitdiffstats
path: root/base/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'base/util.py')
-rw-r--r--base/util.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/base/util.py b/base/util.py
index 5193bcd..acea171 100644
--- a/base/util.py
+++ b/base/util.py
@@ -52,7 +52,7 @@ def rm(tgt):
rmtree(tgt)
else:
remove(tgt)
-
+
def copy(src, dst):
# we're using copyfileobj so we can do this from a URL
if isfile(src):
@@ -71,7 +71,7 @@ def symlink(src, dst):
rm(dst)
sym(abspath(src), abspath(dst))
return dst
-
+
def move(src, dst):
if lexists(dst):
rm(dst)
@@ -112,5 +112,24 @@ def base_dir(tarball):
ti = tarball.next()
return ti.name.split('/')[0]
+_to_close = list()
+_all_closed = False
+
+def close_later(directory):
+ global _to_close
+ if directory not in _to_close:
+ self._to_close.append(directory)
+ return directory
+
+def close_all():
+ global _all_closed
+ global _to_close
+ if _all_closed:
+ return
+ for directory in _to_close:
+ directory.close()
+
+
__all__ = ['pwd', 'copy', 'with_sudo', 'with_su', 'symlink', 'move',
- 'log_file', 'one', 'remove_all', 'flatten', 'base_dir']
+ 'log_file', 'one', 'remove_all', 'flatten', 'base_dir',
+ 'close_later', 'close_all']