Allow users to specify tmp dir for large files
[snf-image-creator] / image_creator / util.py
index 1cd97ff..8730143 100644 (file)
@@ -35,6 +35,7 @@ import sys
 import sh
 import hashlib
 import time
+import os
 
 
 class FatalError(Exception):
@@ -73,6 +74,11 @@ def try_fail_repeat(command, *args):
     raise FatalError("Command: `%s %s' failed" % (command, " ".join(args)))
 
 
+def free_space(dirname):
+    stat = os.statvfs(dirname)
+    return stat.f_bavail * stat.f_frsize
+
+
 class MD5:
     def __init__(self, output):
         self.out = output