def make_temp_dir(prefix, root_dir): """Returns a temporary directory on the same file system as root_dir.""" base_temp_dir = None if (root_dir and not file_path.is_same_filesystem(root_dir, tempfile.gettempdir())): base_temp_dir = os.path.dirname(root_dir) return tempfile.mkdtemp(prefix=prefix, dir=base_temp_dir)
def make_temp_dir(prefix, root_dir=None): """Returns a temporary directory. If root_dir is given and /tmp is on same file system as root_dir, uses /tmp. Otherwise makes a new temp directory under root_dir. """ base_temp_dir = None if root_dir and not file_path.is_same_filesystem(root_dir, tempfile.gettempdir()): base_temp_dir = root_dir return unicode(tempfile.mkdtemp(prefix=prefix, dir=base_temp_dir))
def make_temp_dir(prefix, root_dir=None): """Returns a temporary directory. If root_dir is given and /tmp is on same file system as root_dir, uses /tmp. Otherwise makes a new temp directory under root_dir. """ base_temp_dir = None if (root_dir and not file_path.is_same_filesystem( root_dir, unicode(tempfile.gettempdir()))): base_temp_dir = root_dir return unicode(tempfile.mkdtemp(prefix=prefix, dir=base_temp_dir))
def make_temp_dir(prefix, root_dir=None): """Returns a temporary directory. If root_dir is given and /tmp is on same file system as root_dir, uses /tmp. Otherwise makes a new temp directory under root_dir. Except on OSX, because it's dangerous to create hardlinks in $TMPDIR on OSX! /System/Library/LaunchDaemons/com.apple.bsd.dirhelper.plist runs every day at 3:35am and deletes all files older than 3 days in $TMPDIR, but hardlinks do not have the inode modification time updated, so they tend to be old, thus they get deleted. """ base_temp_dir = None real_temp_dir = unicode(tempfile.gettempdir()) if sys.platform == 'darwin': # Nope! Nope! Nope! assert root_dir, 'It is unsafe to create hardlinks in $TMPDIR' base_temp_dir = root_dir elif root_dir and not file_path.is_same_filesystem(root_dir, real_temp_dir): base_temp_dir = root_dir return unicode(tempfile.mkdtemp(prefix=prefix, dir=base_temp_dir))