From cfd5cb30c2302d4f16ffef06f56f932ea570adac Mon Sep 17 00:00:00 2001 From: Mike O'Connor Date: Fri, 13 Mar 2009 10:00:10 -0400 Subject: [PATCH] move mkdtmp to utils.temp_directory Signed-off-by: Mike O'Connor --- daklib/binary.py | 2 +- daklib/utils.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/daklib/binary.py b/daklib/binary.py index 57b0f65d..136dfed6 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 96bc9bef..6135a19f 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 -- 2.39.5