]> git.decadent.org.uk Git - dak.git/commitdiff
move mkdtmp to utils.temp_directory
authorMike O'Connor <stew@vireo.org>
Fri, 13 Mar 2009 14:00:10 +0000 (10:00 -0400)
committerMike O'Connor <stew@vireo.org>
Fri, 13 Mar 2009 14:00:10 +0000 (10:00 -0400)
Signed-off-by: Mike O'Connor <stew@vireo.org>
daklib/binary.py
daklib/utils.py

index 57b0f65ddd30183f67a670733a6a5d3abe8c5ade..136dfed6150a38ced5275cc0f1aa0734edaf3eb5 100755 (executable)
@@ -110,7 +110,7 @@ class Binary(object):
         # a temporary directory
 
         if not self.tmpdir:
-            tmpdir = tempfile.mkdtemp()
+            tmpdir = utils.temp_dirname()
             cwd = os.getcwd()
             try:
                 os.chdir( tmpdir )
index 96bc9befd8bc920379983d3a1babd11c7cf6448f..6135a19f6f8bdf303d4978f7ce06868f9eef9c4a 100755 (executable)
@@ -1484,6 +1484,20 @@ def temp_filename(directory=None, prefix="dak", suffix=""):
 
 ################################################################################
 
+def temp_dirname(parent=None, prefix="dak", suffix=""):
+    """
+    Return a secure and unique directory by pre-creating it.
+    If 'parent' is non-null, it will be the directory the directory is pre-created in.
+    If 'prefix' is non-null, the filename will be prefixed with it, default is dak.
+    If 'suffix' is non-null, the filename will end with it.
+
+    Returns a pathname to the new directory
+    """
+
+    return tempfile.mkdtemp(suffix, prefix, directory)
+
+################################################################################
+
 def is_email_alias(email):
     """ checks if the user part of the email is listed in the alias file """
     global alias_cache