From: Mike O'Connor Date: Fri, 13 Mar 2009 14:00:10 +0000 (-0400) Subject: move mkdtmp to utils.temp_directory X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfd5cb30c2302d4f16ffef06f56f932ea570adac;p=dak move mkdtmp to utils.temp_directory Signed-off-by: Mike O'Connor --- 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