[dak/master] move mkdtmp to utils.temp_directory
Signed-off-by: Mike O'Connor <stew@vireo.org>
---
daklib/binary.py | 2 +-
daklib/utils.py | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/daklib/binary.py b/daklib/binary.py
index 57b0f65..136dfed 100755
--- a/daklib/binary.py
+++ b/daklib/binary.py
@@ -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 )
diff --git a/daklib/utils.py b/daklib/utils.py
index 96bc9be..6135a19 100755
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -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
--
1.5.6.5
Reply to: